agent-device 0.20.6 → 0.20.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.6.apk → agent-device-android-ime-helper-0.20.8.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.8.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.6.manifest.json → agent-device-android-ime-helper-0.20.8.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.6.apk → agent-device-android-snapshot-helper-0.20.8.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.8.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.6.manifest.json → agent-device-android-snapshot-helper-0.20.8.manifest.json} +6 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +20 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +67 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +339 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSelectorMatchPolicy.swift +78 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +31 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +34 -8
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CoordinateTextEntryTests.swift +4 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +36 -28
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +7 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+RecordingTests.swift +4 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SelectorMatchPolicyTests.swift +4 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +2 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +100 -12
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +4 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +57 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +1 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +18 -3
- package/dist/src/agent-browser-tool.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/app-helpers.js +1 -1
- package/dist/src/app-lifecycle.js +7 -7
- package/dist/src/app-lifecycle2.js +2 -0
- package/dist/src/app-log-files.js +1 -0
- package/dist/src/app-log-reconnect.js +1 -0
- package/dist/src/app-log-runtime.js +4 -0
- package/dist/src/app-resolution.js +2 -1
- package/dist/src/apps.js +5 -5
- package/dist/src/audio-probe.js +1 -1
- package/dist/src/auth-session.js +1 -0
- package/dist/src/auth.js +2 -0
- package/dist/src/boot-diagnostics.js +2 -2
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-grammar.js +1 -0
- package/dist/src/cli-help.js +199 -259
- package/dist/src/cli-output.js +1 -0
- package/dist/src/cli-runner.js +1 -2
- package/dist/src/cli.js +6 -16
- package/dist/src/client-metro.js +1 -1
- package/dist/src/cloud-artifacts.d.ts +2 -137
- package/dist/src/command-schema.js +3 -3
- package/dist/src/connection-runtime.js +1 -0
- package/dist/src/connection.js +5 -0
- package/dist/src/daemon-shutdown-report.js +1 -0
- package/dist/src/daemon.js +2 -0
- package/dist/src/debug-symbols.js +1 -1
- package/dist/src/device-claim-inspection.js +1 -0
- package/dist/src/device-input-state.js +2 -2
- package/dist/src/device-ready.js +1 -0
- package/dist/src/device.js +1 -1
- package/dist/src/device2.js +2 -0
- package/dist/src/dispatch.js +1 -0
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/generic-settle.js +1 -1
- package/dist/src/generic.js +1 -1
- package/dist/src/handler-utils.js +1 -0
- package/dist/src/harmonyos.js +1 -0
- package/dist/src/hdc.js +1 -0
- package/dist/src/host-process.js +3 -2
- package/dist/src/ime-lifecycle.js +7 -7
- package/dist/src/index.d.ts +52 -21
- package/dist/src/input-actions.js +4 -4
- package/dist/src/input-actions2.js +1 -1
- package/dist/src/input-actions3.js +1 -0
- package/dist/src/install-artifact.js +1 -5
- package/dist/src/install-artifact2.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/interaction-runtime.js +1 -1
- package/dist/src/interaction-snapshot.js +1 -1
- package/dist/src/interaction-touch-reference-frame.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interactor.js +2 -2
- package/dist/src/interactor2.js +1 -1
- package/dist/src/internal/bin.js +2 -2
- package/dist/src/internal/daemon.js +7 -36
- package/dist/src/inventory.js +5 -0
- package/dist/src/inventory2.js +1 -0
- package/dist/src/inventory3.js +2 -0
- package/dist/src/inventory4.js +1 -0
- package/dist/src/inventory5.js +1 -0
- package/dist/src/inventory6.js +1 -0
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun-runtime-dependencies.js +1 -0
- package/dist/src/limrun.d.ts +10 -125
- package/dist/src/limrun.js +1 -1
- package/dist/src/linux.js +1 -1
- package/dist/src/logcat.js +1 -1
- package/dist/src/manifest.js +1 -1
- package/dist/src/notifications.js +1 -1
- package/dist/src/output-path.js +1 -0
- package/dist/src/owner-identity.js +1 -0
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/platform-runtime-app-log-android-transport.js +1 -0
- package/dist/src/platform-runtime-app-log-process.js +1 -0
- package/dist/src/platform-runtime-host.js +1 -0
- package/dist/src/platform-runtime-network-web-transport.js +1 -0
- package/dist/src/platform-runtime-operation-host.js +5 -0
- package/dist/src/platform-runtime-screen-recording-android-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-apple-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-apple-runner-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -0
- package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-apple-transport.js +1 -0
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-harmony-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-output-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-web-host.js +1 -0
- package/dist/src/platform-runtime-toolchain-host.js +1 -0
- package/dist/src/platform-runtime.js +1 -0
- package/dist/src/prepare-kind.js +15 -0
- package/dist/src/process-entry.js +1 -0
- package/dist/src/process-lock.js +1 -1
- package/dist/src/provider-webdriver.js +1 -0
- package/dist/src/proxy.js +2 -0
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -0
- package/dist/src/record-trace.js +1 -1
- package/dist/src/recording-telemetry.js +1 -0
- package/dist/src/registry.js +24 -24
- package/dist/src/replay.js +3 -0
- package/dist/src/reporting.js +3 -3
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-lease.js +1 -1
- package/dist/src/runtime.js +3 -3
- package/dist/src/runtime2.js +4 -0
- package/dist/src/runtime3.js +3 -0
- package/dist/src/runtime4.js +1 -0
- package/dist/src/runtime5.js +1 -0
- package/dist/src/runtime6.js +1 -0
- package/dist/src/runtime7.js +1 -0
- package/dist/src/screenshot-result.js +4 -4
- package/dist/src/screenshot.js +1 -0
- package/dist/src/sdk-android-adb.js +4 -4
- package/dist/src/sdk-batch-runner.js +3 -3
- package/dist/src/sdk-contracts.d.ts +31 -5
- package/dist/src/sdk-contracts.js +1 -1
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +285 -5
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selector-vocabulary.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +3 -3
- package/dist/src/session-target-evidence.js +1 -1
- package/dist/src/session.js +10 -9
- package/dist/src/shared.js +2 -0
- package/dist/src/shell-quote.js +1 -0
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -0
- package/dist/src/snapshot-session.js +1 -0
- package/dist/src/snapshot2.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src2.js +2 -0
- package/dist/src/src3.js +1 -0
- package/dist/src/text-surface.js +1 -1
- package/dist/src/timing-safe-equal.js +1 -0
- package/dist/src/tool-provider.js +2 -2
- package/dist/src/update-check.js +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/video.js +23 -0
- package/dist/src/web.js +1 -1
- package/package.json +34 -20
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.6.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.6.apk.sha256 +0 -1
- package/dist/src/app-log-request-scope.js +0 -1
- package/dist/src/context.js +0 -1
- package/dist/src/devices.js +0 -1
- package/dist/src/devices2.js +0 -1
- package/dist/src/devices3.js +0 -1
- package/dist/src/devices4.js +0 -1
- package/dist/src/provider-limrun-runtime.js +0 -1
- package/dist/src/register-builtins.js +0 -1
- package/dist/src/runner-client.js +0 -1
- package/dist/src/runner-provider.js +0 -1
- package/dist/src/screenshot-geometry.js +0 -1
- package/dist/src/viewport-dimension.js +0 -15
- package/skills/agent-device/SKILL.md +0 -45
- package/skills/dogfood/SKILL.md +0 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-device",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.8",
|
|
4
4
|
"description": "Agent-native CLI for AI app automation across iOS, Android, tvOS, Android TV, macOS, Linux, and web.",
|
|
5
5
|
"mcpName": "io.github.callstack/agent-device",
|
|
6
6
|
"license": "MIT",
|
|
@@ -101,15 +101,15 @@
|
|
|
101
101
|
"build:android-ime-helper": "AGENT_DEVICE_ANDROID_HELPER=ime sh ./scripts/build-android-helper.sh $(node -p \"require('./package.json').version\") .tmp/android-ime-helper",
|
|
102
102
|
"package:android-ime-helper": "AGENT_DEVICE_ANDROID_HELPER=ime sh ./scripts/package-android-helper.sh $(node -p \"require('./package.json').version\") .tmp/android-ime-helper",
|
|
103
103
|
"package:android-ime-helper:npm": "rm -rf android/ime-helper/dist && AGENT_DEVICE_ANDROID_HELPER=ime sh ./scripts/package-android-helper.sh $(node -p \"require('./package.json').version\") android/ime-helper/dist",
|
|
104
|
-
"build:macos-helper": "swift build -c release --package-path apple/macos-helper",
|
|
105
|
-
"build:macos-helper:clean": "swift package --package-path apple/macos-helper clean && pnpm build:macos-helper",
|
|
104
|
+
"build:macos-helper": "node --experimental-strip-types scripts/swift-toolchain-tmpdir.ts swift build -c release --package-path apple/macos-helper",
|
|
105
|
+
"build:macos-helper:clean": "node --experimental-strip-types scripts/swift-toolchain-tmpdir.ts swift package --package-path apple/macos-helper clean && pnpm build:macos-helper",
|
|
106
106
|
"build:package": "pnpm build && pnpm build:xcuitest:ios && pnpm build:xcuitest:macos && pnpm build:xcuitest:tvos && pnpm build:xcuitest:visionos && pnpm build:macos-helper:clean && pnpm package:apple-runner:npm && pnpm build:android",
|
|
107
107
|
"package:npm": "pnpm build:package && pnpm check:package",
|
|
108
108
|
"release:prepare": "rm -rf .tmp/release && pnpm check:mcp-metadata && pnpm build:package && pnpm check:package -- --pack-destination .tmp/release",
|
|
109
109
|
"release:publish": "pnpm release:prepare && npm publish --ignore-scripts .tmp/release/*.tgz",
|
|
110
110
|
"ad": "node bin/agent-device.mjs",
|
|
111
111
|
"bench:help-conformance": "node scripts/help-conformance-bench.mjs",
|
|
112
|
-
"maestro:conformance": "node --experimental-strip-types --test packages/maestro/test/conformance/verify.test.ts packages/maestro/test/conformance/differential/run.test.ts packages/maestro/test/conformance/differential/invariants.test.ts",
|
|
112
|
+
"maestro:conformance": "node --experimental-strip-types scripts/node-test-tmpdir.ts --experimental-strip-types --test packages/maestro/test/conformance/verify.test.ts packages/maestro/test/conformance/differential/run.test.ts packages/maestro/test/conformance/differential/invariants.test.ts",
|
|
113
113
|
"maestro:conformance:regenerate": "node --experimental-strip-types scripts/maestro-conformance/regenerate.mjs",
|
|
114
114
|
"maestro:conformance:differential": "node --experimental-strip-types packages/maestro/test/conformance/differential/run.ts",
|
|
115
115
|
"size": "node scripts/size-report.mjs",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"mutation:baseline": "node --experimental-strip-types scripts/mutation/run.ts --update",
|
|
119
119
|
"mutation:check": "node --experimental-strip-types scripts/mutation/run.ts --no-run",
|
|
120
120
|
"mutation:affected": "node --experimental-strip-types scripts/mutation/run.ts --affected",
|
|
121
|
-
"mutation:test": "node --experimental-strip-types --test scripts/mutation/*.test.ts",
|
|
121
|
+
"mutation:test": "node --experimental-strip-types scripts/node-test-tmpdir.ts --experimental-strip-types --test scripts/mutation/*.test.ts",
|
|
122
122
|
"lint": "oxlint . --deny-warnings",
|
|
123
123
|
"format": "node ./node_modules/oxfmt/bin/oxfmt --write",
|
|
124
124
|
"format:check": "node ./node_modules/oxfmt/bin/oxfmt --check",
|
|
@@ -127,19 +127,21 @@
|
|
|
127
127
|
"fallow:baseline": "fallow dead-code --save-baseline fallow-baselines/dead-code.json --summary && fallow health --report-only --save-baseline fallow-baselines/health.json --summary",
|
|
128
128
|
"check:fallow": "fallow audit",
|
|
129
129
|
"check:affected": "node --experimental-strip-types scripts/check-affected/run.ts",
|
|
130
|
-
"check:affected:test": "node --experimental-strip-types --test scripts/check-affected/model.test.ts scripts/check-affected/run.test.ts",
|
|
130
|
+
"check:affected:test": "node --experimental-strip-types scripts/node-test-tmpdir.ts --experimental-strip-types --test scripts/check-affected/model.test.ts scripts/check-affected/platform-packages.test.ts scripts/check-affected/run.test.ts",
|
|
131
131
|
"check:coverage-changed": "node --experimental-strip-types scripts/coverage-changed/run.ts",
|
|
132
|
-
"check:coverage-changed:test": "node --experimental-strip-types --test scripts/coverage-changed/model.test.ts scripts/coverage-changed/run.test.ts",
|
|
133
|
-
"check:layering": "node --experimental-strip-types --test scripts/layering/model.test.ts scripts/layering/zone-policy.test.ts scripts/layering/daemon-modularity.test.ts scripts/layering/package-boundaries.test.ts scripts/layering/facade-exports.test.ts scripts/layering/bin-alias-fast-path.test.ts && node --experimental-strip-types scripts/layering/check.ts",
|
|
132
|
+
"check:coverage-changed:test": "node --experimental-strip-types scripts/node-test-tmpdir.ts --experimental-strip-types --test scripts/coverage-changed/model.test.ts scripts/coverage-changed/run.test.ts",
|
|
133
|
+
"check:layering": "node --experimental-strip-types scripts/node-test-tmpdir.ts --experimental-strip-types --test scripts/layering/model.test.ts scripts/layering/zone-policy.test.ts scripts/layering/daemon-modularity.test.ts scripts/layering/package-boundaries.test.ts scripts/layering/platform-package-policy.test.ts scripts/layering/platform-package-repository.test.ts scripts/layering/platform-package-source-policy.test.ts scripts/layering/device-inventory-cutover-policy.test.ts scripts/layering/logs-runtime-cutover-policy.test.ts scripts/layering/network-runtime-cutover-policy.test.ts scripts/layering/record-runtime-cutover-policy.test.ts scripts/layering/contracts-implementation-policy.test.ts scripts/layering/facade-exports.test.ts scripts/layering/bin-alias-fast-path.test.ts && node --experimental-strip-types scripts/layering/check.ts",
|
|
134
134
|
"depgraph": "node --experimental-strip-types scripts/depgraph/build.ts",
|
|
135
|
-
"depgraph:test": "node --experimental-strip-types --test scripts/depgraph/model.test.ts scripts/depgraph/affected.test.ts",
|
|
135
|
+
"depgraph:test": "node --experimental-strip-types scripts/node-test-tmpdir.ts --experimental-strip-types --test scripts/depgraph/model.test.ts scripts/depgraph/affected.test.ts",
|
|
136
136
|
"check:production-exports": "fallow dead-code --config fallow-production-exports.json --production --unused-exports --fail-on-issues",
|
|
137
137
|
"check:bundle-owner-files": "node --experimental-strip-types scripts/check-bundle-owner-files.ts",
|
|
138
138
|
"check:package": "node --experimental-strip-types scripts/check-package.ts",
|
|
139
139
|
"check:command-docs": "vitest run --project unit-core src/__tests__/command-doc-coverage.test.ts",
|
|
140
140
|
"check:replay-compat": "node --experimental-strip-types scripts/check-replay-compat-provenance.ts",
|
|
141
|
+
"check:daemon-wire-compat": "node --experimental-strip-types scripts/wire-compat/run.ts",
|
|
142
|
+
"check:daemon-wire-compat:test": "node --experimental-strip-types scripts/node-test-tmpdir.ts --experimental-strip-types --test scripts/wire-compat/model.test.ts",
|
|
141
143
|
"check:tmpdir-leaks": "node --experimental-strip-types scripts/check-tmpdir-leaks.ts",
|
|
142
|
-
"check:tmpdir-leaks:test": "node --experimental-strip-types --test scripts/check-tmpdir-leaks-model.test.ts scripts/vitest-tmpdir-global-setup.test.ts",
|
|
144
|
+
"check:tmpdir-leaks:test": "node --experimental-strip-types scripts/node-test-tmpdir.ts --experimental-strip-types --test scripts/check-tmpdir-leaks-model.test.ts scripts/vitest-tmpdir-global-setup.test.ts scripts/node-test-tmpdir.test.ts scripts/swift-toolchain-tmpdir.test.ts",
|
|
143
145
|
"check:freerange": "fr",
|
|
144
146
|
"check:quick": "pnpm lint && pnpm typecheck",
|
|
145
147
|
"sync:mcp-metadata": "node scripts/sync-mcp-metadata.mjs",
|
|
@@ -149,7 +151,7 @@
|
|
|
149
151
|
"check:unit": "pnpm check:contention-retry && pnpm test:unit && pnpm check:tmpdir-leaks && pnpm test:smoke",
|
|
150
152
|
"check": "pnpm check:tooling && pnpm check:fallow && pnpm check:unit",
|
|
151
153
|
"prepack": "pnpm check:mcp-metadata && pnpm package:npm",
|
|
152
|
-
"typecheck": "tsc -b packages/xml packages/kernel packages/contracts packages/ad-script packages/selectors packages/ad-replay packages/maestro packages/replay-test packages/provider-webdriver packages/provider-limrun && tsc -p tsconfig.json && tsc -p examples/sdk/tsconfig.json",
|
|
154
|
+
"typecheck": "tsc -b packages/xml packages/kernel packages/contracts packages/capture-kit packages/platform-apple packages/platform-android packages/platform-harmonyos packages/platform-vega packages/platform-linux packages/platform-web packages/ad-script packages/selectors packages/ad-replay packages/maestro packages/replay-test packages/provider-webdriver packages/provider-limrun && tsc -p tsconfig.json && tsc -p examples/sdk/tsconfig.json",
|
|
153
155
|
"test-app:install": "pnpm install --dir examples/test-app",
|
|
154
156
|
"test-app:start": "pnpm --dir examples/test-app start",
|
|
155
157
|
"test-app:ios": "pnpm --dir examples/test-app ios",
|
|
@@ -165,17 +167,17 @@
|
|
|
165
167
|
"test:maestro-compat": "vitest run --project unit-core packages/maestro src/daemon/adapters/maestro src/compat/__tests__/replay-input.test.ts",
|
|
166
168
|
"test:coverage": "vitest run --coverage",
|
|
167
169
|
"test:coverage:ci": "node --experimental-strip-types scripts/lib/contention-retry-run.ts --coverage",
|
|
168
|
-
"check:contention-retry": "node --experimental-strip-types --test scripts/lib/contention-retry-policy.test.ts",
|
|
170
|
+
"check:contention-retry": "node --experimental-strip-types scripts/node-test-tmpdir.ts --experimental-strip-types --test scripts/lib/contention-retry-policy.test.ts",
|
|
169
171
|
"test:integration:provider": "vitest run --project provider-integration",
|
|
170
172
|
"test:integration:progress": "node --experimental-strip-types scripts/integration-progress.ts",
|
|
171
173
|
"test:integration:progress:check": "node --experimental-strip-types scripts/integration-progress.ts --check",
|
|
172
|
-
"test:fixture-cache": "node --test test/ci/trusted-fixture-artifact.test.mjs",
|
|
174
|
+
"test:fixture-cache": "node --experimental-strip-types scripts/node-test-tmpdir.ts --test test/ci/trusted-fixture-artifact.test.mjs",
|
|
173
175
|
"test:output-economy": "vitest run --project output-economy",
|
|
174
|
-
"test:smoke:web": "pnpm build && node --test test/integration/smoke-web-platform.test.ts",
|
|
175
|
-
"test:smoke": "node --test test/integration/smoke-*.test.ts",
|
|
176
|
-
"test:integration:node": "node --test test/integration/*.test.ts",
|
|
176
|
+
"test:smoke:web": "pnpm build && node --experimental-strip-types scripts/node-test-tmpdir.ts --test test/integration/smoke-web-platform.test.ts",
|
|
177
|
+
"test:smoke": "node --experimental-strip-types scripts/node-test-tmpdir.ts --test test/integration/smoke-*.test.ts",
|
|
178
|
+
"test:integration:node": "node --experimental-strip-types scripts/node-test-tmpdir.ts --test --experimental-test-isolation=none test/integration/*.test.ts",
|
|
177
179
|
"test:integration": "pnpm test:integration:node && pnpm test:integration:provider",
|
|
178
|
-
"test:concurrency-torture": "node --test test/integration/nightly/concurrency-torture.test.ts",
|
|
180
|
+
"test:concurrency-torture": "node --experimental-strip-types scripts/node-test-tmpdir.ts --test test/integration/nightly/concurrency-torture.test.ts",
|
|
179
181
|
"test:replay:ios": "node --experimental-strip-types src/bin.ts test test/integration/replays/ios/simulator",
|
|
180
182
|
"test:replay:ios-device": "node --experimental-strip-types src/bin.ts test test/integration/replays/ios/device",
|
|
181
183
|
"test:replay:android": "node --experimental-strip-types src/bin.ts test test/integration/replays/android",
|
|
@@ -194,7 +196,6 @@
|
|
|
194
196
|
"!android/ime-helper/dist/*.idsig",
|
|
195
197
|
"!android/ime-helper/README.md",
|
|
196
198
|
"linux/atspi-dump.py",
|
|
197
|
-
"skills",
|
|
198
199
|
"server.json",
|
|
199
200
|
"smithery.yaml",
|
|
200
201
|
"README.md",
|
|
@@ -245,18 +246,29 @@
|
|
|
245
246
|
],
|
|
246
247
|
"dependencies": {
|
|
247
248
|
"@limrun/api": "^0.24.5",
|
|
248
|
-
"
|
|
249
|
+
"ipaddr.js": "^2.5.0",
|
|
250
|
+
"tar-stream": "^3.2.0",
|
|
251
|
+
"undici": "7.29.0",
|
|
252
|
+
"yaml": "^2.9.0",
|
|
253
|
+
"yauzl": "^3.4.0"
|
|
249
254
|
},
|
|
250
255
|
"devDependencies": {
|
|
256
|
+
"@agent-device/capture-kit": "workspace:*",
|
|
251
257
|
"@agent-device/ad-replay": "workspace:*",
|
|
252
258
|
"@agent-device/ad-script": "workspace:*",
|
|
253
259
|
"@agent-device/contracts": "workspace:*",
|
|
254
260
|
"@agent-device/kernel": "workspace:*",
|
|
255
|
-
"@agent-device/selectors": "workspace:*",
|
|
256
261
|
"@agent-device/maestro": "workspace:*",
|
|
262
|
+
"@agent-device/platform-android": "workspace:*",
|
|
263
|
+
"@agent-device/platform-apple": "workspace:*",
|
|
264
|
+
"@agent-device/platform-harmonyos": "workspace:*",
|
|
265
|
+
"@agent-device/platform-linux": "workspace:*",
|
|
266
|
+
"@agent-device/platform-vega": "workspace:*",
|
|
267
|
+
"@agent-device/platform-web": "workspace:*",
|
|
257
268
|
"@agent-device/provider-limrun": "workspace:*",
|
|
258
269
|
"@agent-device/provider-webdriver": "workspace:*",
|
|
259
270
|
"@agent-device/replay-test": "workspace:*",
|
|
271
|
+
"@agent-device/selectors": "workspace:*",
|
|
260
272
|
"@agent-device/xml": "workspace:*",
|
|
261
273
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
262
274
|
"@chenglou/freerange": "^0.0.1",
|
|
@@ -264,6 +276,8 @@
|
|
|
264
276
|
"@stryker-mutator/vitest-runner": "9.6.1",
|
|
265
277
|
"@types/node": "^22.19.21",
|
|
266
278
|
"@types/pngjs": "^6.0.5",
|
|
279
|
+
"@types/tar-stream": "^3.1.4",
|
|
280
|
+
"@types/yauzl": "^2.10.3",
|
|
267
281
|
"@vitest/coverage-v8": "4.1.8",
|
|
268
282
|
"fallow": "^2.95.0",
|
|
269
283
|
"fast-check": "^4.9.0",
|
package/server.json
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
"url": "https://github.com/callstack/agent-device",
|
|
8
8
|
"source": "github"
|
|
9
9
|
},
|
|
10
|
-
"version": "0.20.
|
|
10
|
+
"version": "0.20.8",
|
|
11
11
|
"packages": [
|
|
12
12
|
{
|
|
13
13
|
"registryType": "npm",
|
|
14
14
|
"identifier": "agent-device",
|
|
15
|
-
"version": "0.20.
|
|
15
|
+
"version": "0.20.8",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
7f719c5e1698e827948a9de22bf31aab065d7f2cb7d17731793b586fd3f88f4f agent-device-android-ime-helper-0.20.6.apk
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
696f8e518bbc2ad66225cb80f2e9e70d2b19b75d382918edd8fce3009200e434 agent-device-android-snapshot-helper-0.20.6.apk
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{it as e}from"./internal/daemon.js";export{e as withAppLogProvider};
|
package/dist/src/context.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e}from"./sdk-contracts.js";import{A as t,At as n,Mt as r,O as i,S as a,ct as o,d as s,it as c,j as l,k as u,lt as d}from"./screenshot-geometry.js";import{a as f,h as p,s as m}from"./sdk-batch-runner.js";import{_ as ee,c as h,f as te,h as g,o as _,p as ne,s as v,v as y}from"./sdk-device.js";import{Ht as re,Vt as b,ct as ie,fn as x,lt as ae,pn as S,st as C,t as oe,ut as se}from"./viewport-dimension.js";import{M as ce}from"./screenshot-result.js";import{_ as le,a as ue}from"./device.js";import{f as de}from"./runtime.js";import{I as fe,N as pe,j as w}from"./sdk-android-adb.js";import{t as me}from"./timeouts.js";import{a as he,o as ge}from"./boot-diagnostics.js";import{i as _e}from"./lease-context.js";import{i as T,n as ve,r as E,t as D}from"./register-builtins.js";import ye from"node:path";import{AsyncLocalStorage as O}from"node:async_hooks";import be,{promises as k}from"node:fs";let xe=[];const A=new O;async function Se(e,t){return await A.run([...e],t)}function Ce(e,t){for(let n of M()){if(!n.ownsDevice(e))continue;let r=n.getInteractor(e,t);if(r)return r}}function j(e){return M().some(t=>t.ownsDevice(e))}async function we(e,t,n,r){for(let i of M()){if(!i.ownsDevice(e))continue;if(!i.installApp)throw I(i,e,`install`);let a=await i.installApp?.(e,t,n,r);if(a)return a;throw I(i,e,`install`)}}async function Te(e,t,n){for(let r of M()){if(!r.ownsDevice(e))continue;if(!r.installInstallablePath)throw I(r,e,`install_from_source`);let i=await r.installInstallablePath?.(e,t,n);if(i)return i;throw I(r,e,`install_from_source`)}}async function Ee(e){for(let t of M()){if(!F(t,e.provider))continue;let n=await t.configurePortReverse?.(e);if(n)return n}}function M(){return A.getStore()??xe}function De(e,t={}){let n=e.map(e=>e.provider);return{providerRuntimeIds:n,providerRuntimeRequiredIds:Ae([...n,...t.providerRuntimeRequiredIds??[]]),leaseLifecycleProvider:je(e),recoverableProviderIds:e.filter(e=>e.recoverExpiredLease!==void 0).map(e=>e.provider),recoverExpiredLease:ke(e),cloudArtifactProvider:Me(e),deviceInventoryProvider:Ne(e),appleRunnerProvider:Oe(e),providerDeviceRuntimeScope:async t=>await Se(e,t)}}function Oe(e){if(e.some(N))return t=>{for(let n of e){if(!N(n)||!n.ownsDevice(t.device))continue;let e=n.getAppleRunnerProvider(t.device);if(e)return e}}}function N(e){return`getAppleRunnerProvider`in e&&typeof e.getAppleRunnerProvider==`function`}function ke(t){if(t.some(e=>e.recoverExpiredLease!==void 0))return async n=>{let r=t.find(e=>F(e,n.leaseProvider));if(!r?.recoverExpiredLease)throw new e(`UNSUPPORTED_OPERATION`,`Provider ${n.leaseProvider??`unknown`} cannot recover an expired lease.`,{provider:n.leaseProvider,leaseId:n.leaseId});await r.recoverExpiredLease(n)}}function Ae(e){return[...new Set(e)]}function je(e){if(e.length!==0)return{allocate:async(t,n)=>await P(e,`allocate`,t,n),heartbeat:async(t,n)=>await P(e,`heartbeat`,t,n),release:async(t,n)=>await P(e,`release`,t,n)}}function Me(e){if(e.length!==0)return{listCloudArtifacts:async t=>await Pe(e,t)}}function Ne(e){if(e.length!==0)return async t=>{for(let n of e){if(!F(n,t.leaseProvider))continue;let e=await n.deviceInventoryProvider(t);if(e)return e}return null}}async function Pe(e,t){for(let n of e){if(!F(n,t.provider))continue;let e=await n.cloudArtifacts?.listCloudArtifacts?.(t);if(e)return e}}async function P(e,t,n,r){for(let i of e){if(!F(i,n.leaseProvider))continue;let e=i.leaseLifecycle[t],a=e?await e(n,r):void 0;if(a)return a}}function F(e,t){return e.provider===t}function I(t,n,r){throw new e(`UNSUPPORTED_OPERATION`,`Provider device runtime ${t.provider} does not support ${r} for this device.`,{provider:t.provider,deviceId:n.id,platform:g(n)})}const L=new O,R=new O;async function z(t,n,r){let i=await Fe(t,n,r);if(i)return i;let a=await Ie(t,n,r);if(r.allowLocalSimulatorFallback!==!1&&Re(n,a)){let{findBootableIosSimulator:e}=await import(`./devices2.js`),t=await e({simulatorSetPath:r.simulatorSetPath,target:n.target});if(t)return t}if(a)return a;throw new e(`DEVICE_NOT_FOUND`,`No devices found`,{selector:n})}async function Fe(t,n,r){let i=r.appleSimulatorAppTarget?.trim();if(!i||V(n)||r.allowLocalSimulatorFallback===!1)return;let a=t.filter(e=>ne(e,n)&&v(e)&&e.kind===`simulator`&&e.booted===!0);if(a.length<2)return;let{findIosSimulatorInstalledApp:o}=await import(`./apps.js`).then(e=>e.t),s=(await Promise.all(a.map(async e=>await o(e,i)?e:void 0))).filter(e=>e!==void 0);if(s.length===1)return s[0];throw s.length===0?new e(`APP_NOT_INSTALLED`,`No booted iOS simulator has ${i} installed`,{appTarget:i,...B(a),hint:`Install the app on a booted simulator, or pass --udid to select the intended device explicitly.`}):new e(`AMBIGUOUS_MATCH`,`Multiple booted iOS simulators have ${i} installed`,{appTarget:i,...B(s),hint:`Pass --udid to select the intended simulator explicitly.`})}function B(e){return{devices:e.map(e=>({id:e.id,name:e.name}))}}async function Ie(e,t,n){try{return await y(e,t,n)}catch(e){if(Le(e,t))return;throw e}}function Le(t,n){return!V(n)&&t instanceof e&&t.code===`DEVICE_NOT_FOUND`}function Re(e,t){return!V(e)&&(!e.platform||e.platform===`apple`||e.platform===`ios`)&&e.target!==`desktop`&&(!t||t.kind===`device`)}function V(e){return!!(e.udid||e.serial||e.deviceName)}async function ze(e,t={}){let n=Be(e),{iosSimulatorSetPath:r,...i}=n,a=Ye(n,t),o={simulatorSetPath:r,allowStoppedAndroidAvdPlaceholders:t.allowStoppedAndroidAvdPlaceholders},s={platform:n.platform,target:e.target,cacheHit:!1};return await fe(`resolve_target_device`,async()=>{let e=Je(a);if(e)return s.cacheHit=!0,e;let c=await Ge(n);if(c)return qe(i)?H(a,await z(c,i,{simulatorSetPath:r,allowLocalSimulatorFallback:n.leaseProvider===void 0,appleSimulatorAppTarget:t.appleSimulatorAppTarget})):H(a,await y(c,i,o));let l=await T(n);return qe(i)?H(a,await z(l,i,{simulatorSetPath:r,appleSimulatorAppTarget:t.appleSimulatorAppTarget})):H(a,await y(l,i,o))},s)}function Be(t){let n=t.platform;if(t.target&&!n)throw new e(`INVALID_ARGS`,`Device target selector requires --platform. Use --platform ios|macos|android|vega|linux|apple with --target mobile|tv|desktop.`);let r=ee({simulatorSetPath:ge(t.iosSimulatorDeviceSet),platform:n,target:t.target}),i=he(t.androidDeviceAllowlist);return{platform:n,target:t.target,deviceName:t.device,udid:t.udid,serial:t.serial,leaseId:t.leaseId,leaseProvider:t.leaseProvider,deviceKey:t.deviceKey,clientId:t.clientId,iosSimulatorSetPath:r,androidSerialAllowlist:i?Array.from(i).sort():void 0}}async function Ve(e){return L.getStore()?await e():await L.run(new Map,e)}async function He(e,t){return e?await R.run(e,t):await t()}async function Ue(e,t){return await He(e,async()=>await Ve(t))}async function We(e){return await Ge(e)??await T(e)}async function Ge(e){let t=R.getStore();if(!t)return null;let n=await t(e);return n==null?null:n.map(e=>({...e}))}function Ke(e){return _(e.platform)}function qe(e){return Ke(e)}function Je(e){let t=L.getStore()?.get(e);if(t)return{...t}}function H(e,t){return L.getStore()?.set(e,{...t}),t}function Ye(e,t){let{appleSimulatorAppTarget:n,...r}=t;return JSON.stringify({request:e,options:r})}D();const Xe={device:!0},Ze=[`open`,`close`],Qe=[`record`],$e=[`audio`,`find`,`get`,`is`,`network`,`screenshot`,`snapshot`,`wait`],et=[`click`,`fill`,`focus`,`press`,`scroll`,`type`],tt=[`viewport`],nt=new Set([...Ze,...Qe,...$e,...et,...tt]),U=rt(f(p));function rt(e){let t={};for(let[n,r]of Object.entries(e))t[n]=nt.has(n)?{...r,web:Xe}:r;for(let t of nt)if(!(t in e))throw Error(`Web command "${t}" missing from capability matrix`);return t}function it(e,t){let n=U[e];if(!n)return!0;let r=E(t.platform);if(!r)return!1;let i=n[r.capability.bucket];if(!i)return!1;let a=r.capability.supportsByDefault?.[e];return a&&!a(t)?!1:i[t.kind??`unknown`]===!0}function at(e,t){return E(t.platform)?.capability.unsupportedHintByDefault?.[e]?.(t)}function ot(){return Object.keys(U).sort()}function st(e){let t=U[e];if(!t)return[];let n=[`apple`,`android`,`vega`,`linux`,`web`],r=[];for(let e of n){let n=t[e];n&&Object.values(n).some(e=>e===!0)&&r.push(e)}return r}function ct(e,t){if(e.intent===`drag`){lt(e,t);return}if(t.platform===`web`||t.appleOs===`watchos`)throw G(e,W(e,t));if(ut(e)){dt(e,t);return}if(t.appleOs===`visionos`)throw G(e,W(e,t));if(e.intent===`fling`&&`direction`in e&&t.platform===`linux`)throw G(e,`gesture fling is not supported on Linux`)}function lt(e,t){let n=t.platform===`android`&&t.target!==`tv`,r=t.platform===`apple`&&(t.appleOs===`ios`||t.appleOs===`ipados`||t.appleOs===void 0&&t.target!==`desktop`&&t.target!==`tv`);if(!(n||r))throw G(e,W(e,t),`Target-authored drag requires an adapter that preserves source hold, timed movement, and destination hold; it is supported on Android touch devices and iOS/iPadOS.`)}function ut(e){return e.intent===`pan`?(`pointerCount`in e?e.pointerCount:1)===2:e.intent===`pinch`||e.intent===`rotate`||e.intent===`transform`}function dt(e,t){if(t.platform===`android`){if(t.target!==`tv`)return;throw G(e,`gesture ${e.intent} is not supported on Android TV`,`Android TV has no touch input — this gesture is supported on Android phones, tablets, and the iOS simulator only.`)}if(t.platform!==`apple`)throw G(e,W(e,t));le(t,e.intent)}function W(e,t){return`gesture ${e.intent} is not supported on ${t.appleOs??t.platform}`}function G(t,n,r){return new e(`UNSUPPORTED_OPERATION`,n,{gesture:t.intent,...r?{hint:r}:{}})}const ft=`No active session. Run open first.`;function pt(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}function mt(){return pt(`SESSION_NOT_FOUND`,ft)}function ht(e,t,n){if(it(e,t))return null;let r=n?.hint?at(e,t):void 0;return{ok:!1,error:{code:`UNSUPPORTED_OPERATION`,message:n?.message??`${e} is not supported on this device`,...r?{hint:r}:{}}}}const gt=/^[A-Za-z0-9_.:-]{1,64}$/,_t=8*1024,vt=4*1024;function yt(t){let n=t[0]?.trim(),r=t[1]?.trim();if(!n)throw new e(`INVALID_ARGS`,`trigger-app-event requires <event> [payloadJson]`);if(!gt.test(n))throw new e(`INVALID_ARGS`,`Invalid trigger-app-event event name: ${n}`,{hint:`Use 1-64 chars: letters, numbers, underscore, dot, colon, or dash.`});if(t.length>2)throw new e(`INVALID_ARGS`,`trigger-app-event accepts at most two arguments: <event> [payloadJson]`);return{eventName:n,payload:xt(r,n)}}function bt(t,n,r){let i=g(t),a=St(t);if(!a)throw new e(`UNSUPPORTED_OPERATION`,`No app event URL template configured for ${i}.`,{hint:`Set AGENT_DEVICE_${i.toUpperCase()}_APP_EVENT_URL_TEMPLATE or AGENT_DEVICE_APP_EVENT_URL_TEMPLATE, for example "myapp://agent-device/event?name={event}&payload={payload}".`});let o=r?JSON.stringify(r):``,s=a.replaceAll(`{event}`,encodeURIComponent(n)).replaceAll(`{payload}`,encodeURIComponent(o)).replaceAll(`{platform}`,encodeURIComponent(i));if(s.length>vt)throw new e(`INVALID_ARGS`,`trigger-app-event URL exceeds maximum supported length`,{hint:`Reduce payload size or shorten AGENT_DEVICE_*_APP_EVENT_URL_TEMPLATE.`,length:s.length,maxLength:vt});return s}function xt(t,n){if(t)try{let r=JSON.parse(t);if(!r||typeof r!=`object`||Array.isArray(r))throw new e(`INVALID_ARGS`,`trigger-app-event payload for "${n}" must be a JSON object`);let i=JSON.stringify(r);if(Buffer.byteLength(i,`utf8`)>_t)throw new e(`INVALID_ARGS`,`trigger-app-event payload for "${n}" exceeds ${_t} bytes`);return r}catch(n){throw n instanceof e?n:new e(`INVALID_ARGS`,`Invalid trigger-app-event payload JSON: ${t}`)}}function St(e){return((v(e)?process.env.AGENT_DEVICE_IOS_APP_EVENT_URL_TEMPLATE:h(e)?process.env.AGENT_DEVICE_MACOS_APP_EVENT_URL_TEMPLATE:process.env.AGENT_DEVICE_ANDROID_APP_EVENT_URL_TEMPLATE)??process.env.AGENT_DEVICE_APP_EVENT_URL_TEMPLATE)?.trim()||void 0}const Ct=[[0,0],[1,0],[0,1],[-1,0],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]];function wt(e,t){return _(e.platform)&&t>1}function Tt(e,t,n=2e4){if(e.length===0)return[];let r=t>0?t:e.length,i=[],a=[],o=0;for(let t of e){let e=(t.durationMs??0)+(t.pauseMs??0)+250,s=a.length>0&&o+e>n,c=a.length>=r;(s||c)&&(i.push(a),a=[],o=0),a.push(t),o+=e}return a.length>0&&i.push(a),i}function Et(e,t){if(t<=0)return[0,0];let[n,r]=Ct[e%Ct.length];return[n*t,r*t]}async function Dt(e,t,n){for(let r=0;r<e;r+=1)await n(r),r<e-1&&t>0&&await me(t)}async function Ot(e,t){let{x:n,y:r}=K(t,`longpress requires x y [durationMs]`,{hint:`Direct platform longpress requires coordinates. In an open daemon session, use agent-device longpress @ref|selector [durationMs]; otherwise run snapshot -i, use the target rect center as x y, then retry longpress x y durationMs.`}),i=t[2]?Number(t[2]):void 0;return await e.longPress(n,r,i),{x:n,y:r,durationMs:i,...x(`Long pressed (${n}, ${r})`)}}async function kt(e,t){let{x:n,y:r}=K(t,`focus requires x y`);return await e.focus(n,r),{x:n,y:r,...x(`Focused (${n}, ${r})`)}}async function At(t,n,r){let i=tn(n);if(i)throw new e(`INVALID_ARGS`,`type does not accept a target ref like "${i}"`,{hint:`Use fill ${i} "text" to target that field, or press ${i} then type "text" to append.`});let a=n.join(` `);if(!a)throw new e(`INVALID_ARGS`,`type requires text`);let o=C(r?.delayMs??0,`delay-ms`,0,1e4),s=(await t.type(a,o))?.textEntryRoute;return{...s===void 0?{}:{textEntryRoute:s},text:a,delayMs:o,...x(Y(`Typed`,a))}}async function jt(t,n,r){if(r?.directElementSelector)return await Mt(t,r.directElementSelector,n,r);let i=Number(n[0]),a=Number(n[1]),o=n.slice(2).join(` `);if(Number.isNaN(i)||Number.isNaN(a)||!o)throw new e(`INVALID_ARGS`,`fill requires x y text`);let s=C(r?.delayMs??0,`delay-ms`,0,1e4);return{x:i,y:a,text:o,delayMs:s,...(await t.fill(i,a,o,s,{allowNonHittableCoordinateFallback:r?.allowNonHittableCoordinateFallback===!0}))?.maestroNonHittableCoordinateFallbackUsed===!0?{maestroNonHittableCoordinateFallbackUsed:!0}:{},...x(Y(`Filled`,o))}}async function Mt(t,n,r,i){if(!t.fillElementSelector)throw new e(`UNSUPPORTED_OPERATION`,`direct element selector fill is not supported`);let a=r.join(` `);if(!a)throw new e(`INVALID_ARGS`,`fill requires text`);let o=C(i.delayMs??0,`delay-ms`,0,1e4),s=await t.fillElementSelector(n,a,o);return{selector:n.raw,text:a,delayMs:o,...s??{},...x(Y(`Filled`,a))}}async function Nt(e,t,n,r){if(r?.directElementSelector&&v(e))return await Pt(t,r.directElementSelector);let{x:i,y:a}=K(n,`press requires x y`);if(h(e)&&r?.surface&&r.surface!==`app`)return await Ft(i,a,r);let o=d(r);if(o!==`primary`)return await It(e,i,a,o,r);let s=zt(r);return Bt(s),wt(e,s.count)?await Ht(e,i,a,s,r):await Gt(t,i,a,s)}async function Pt(t,n){if(!t.tapElementSelector)throw new e(`UNSUPPORTED_OPERATION`,`direct element selector tap is not supported`);let r=await t.tapElementSelector(n),i=r?.maestroNonHittableCoordinateFallbackUsed===!0;return{selector:n.raw,...r??{},...x(i?l:`Tapped ${n.raw}`)}}function K(t,n,r){let i=Number(t[0]),a=Number(t[1]);if(Number.isNaN(i)||Number.isNaN(a))throw new e(`INVALID_ARGS`,n,r);return{x:i,y:a}}async function Ft(t,n,r){let i=d(r);if(i!==`primary`)throw new e(`UNSUPPORTED_OPERATION`,`${i} click is not supported on macOS ${r.surface} sessions.`);let{runMacOsPressAction:a}=await import(`./helper.js`).then(e=>e.t);return await a(t,n,{bundleId:r.appBundleId,surface:r.surface}),{x:t,y:n,...x(J({x:t,y:n}))}}async function It(e,t,n,r,i){if(Lt(e,r,i),e.platform===`linux`)return await Rt(t,n,r);let{runAppleRunnerCommand:a}=await import(`./runner-client.js`).then(e=>e.o);return await a(e,{command:`mouseClick`,x:t,y:n,button:r,appBundleId:i?.appBundleId},Kt(i)),{x:t,y:n,button:r,...x(J({x:t,y:n,button:r}))}}function Lt(e,t,n){let r=o({commandLabel:`click`,platform:g(e),button:t,count:n?.count,intervalMs:n?.intervalMs,holdMs:n?.holdMs,jitterPx:n?.jitterPx,doubleTap:n?.doubleTap});if(r)throw r}async function Rt(e,t,n){if(n===`secondary`){let{rightClickLinux:n}=await import(`./input-actions2.js`);await n(e,t)}else{let{middleClickLinux:n}=await import(`./input-actions2.js`);await n(e,t)}return{x:e,y:t,button:n,...x(J({x:e,y:t,button:n}))}}function zt(e){return{count:q(e?.count,1,`count`,1,200),intervalMs:q(e?.intervalMs,0,`interval-ms`,0,1e4),holdMs:q(e?.holdMs,0,`hold-ms`,0,1e4),jitterPx:q(e?.jitterPx,0,`jitter-px`,0,100),doubleTap:!!e?.doubleTap}}function q(e,t,n,r,i){return C(e===void 0?t:e,n,r,i)}function Bt({doubleTap:t,holdMs:n,jitterPx:r}){if(t&&n>0)throw new e(`INVALID_ARGS`,`double-tap cannot be combined with hold-ms`);if(t&&r>0)throw new e(`INVALID_ARGS`,`double-tap cannot be combined with jitter-px`)}async function Vt(e,t,n){let{runAppleRunnerCommand:r}=await import(`./runner-client.js`).then(e=>e.o),{MAX_RUNNER_SEQUENCE_STEPS:i,buildRunnerSequenceCommand:a,parseRunnerSequenceResult:o}=await import(`./runner-sequence.js`).then(e=>e.r),s=Tt(t,i),c,l,u=0,d=[],f=0;for(let t of s){let i=await r(e,a(t,n?.appBundleId),Kt(n));c??=i,l=i;let s;try{s=o(i)}catch(e){throw Wt(e,f)}u+=s.completedSteps,d.push(...s.results),f+=t.length}return{...c??{},completedSteps:u,sequenceResults:d,...l?.gestureEndUptimeMs===void 0?{}:{gestureEndUptimeMs:l.gestureEndUptimeMs}}}async function Ht(e,t,n,r,i){let a=await Vt(e,Ut(e,t,n,r),i);return{x:t,y:n,count:r.count,intervalMs:r.intervalMs,holdMs:r.holdMs,jitterPx:r.jitterPx,doubleTap:r.doubleTap,timingMode:`runner-sequence`,...a,...x(J({x:t,y:n}))}}function Ut(e,t,n,r){let i=r.doubleTap?`doubleTap`:r.holdMs>0?`longPress`:`tap`,a=i===`tap`&&v(e)&&!te(e);return Array.from({length:r.count},(e,o)=>{let[s,c]=Et(o,r.jitterPx),l=o===r.count-1;return{kind:i,x:t+s,y:n+c,...a?{synthesized:!0}:{},...r.holdMs>0?{durationMs:r.holdMs}:{},...!l&&r.intervalMs>0?{pauseMs:r.intervalMs}:{}}})}function Wt(t,n){if(n===0||!(t instanceof e)||!t.details)return t;let r=t.details.failedStepIndex;if(typeof r!=`number`)return t;let i=t.details.completedSteps;return new e(t.code,t.message,{...t.details,failedStepIndex:r+n,chunkStepIndex:r,...typeof i==`number`?{completedSteps:n+i}:{}},t.cause)}async function Gt(e,t,n,r){let i;return await Dt(r.count,r.intervalMs,async a=>{let[o,s]=Et(a,r.jitterPx),c=t+o,l=n+s;if(r.doubleTap){let t=await e.doubleTap(c,l);i??=t??void 0;return}if(r.holdMs>0){let t=await e.longPress(c,l,r.holdMs);i??=t??void 0}else{let t=await e.tap(c,l);i??=t??void 0}}),S({x:t,y:n,count:r.count,intervalMs:r.intervalMs,holdMs:r.holdMs,jitterPx:r.jitterPx,doubleTap:r.doubleTap,...i},J({x:t,y:n}))}function Kt(e){return{verbose:e?.verbose,logPath:e?.logPath,traceLogPath:e?.traceLogPath,requestId:e?.requestId,iosXctestrunFile:e?.iosXctestrunFile,iosXctestDerivedDataPath:e?.iosXctestDerivedDataPath,iosXctestEnvDir:e?.iosXctestEnvDir}}async function qt(t,n,r){let i=n[0],a=n[1]?Number(n[1]):void 0,o=r?.pixels,s=r?.durationMs;if(!i)throw new e(`INVALID_ARGS`,`scroll requires direction`);Jt(a,o,s);let c=$t(i),l={amount:a,pixels:o,durationMs:s},{interactionResult:u,completedPasses:d}=await Xt(t,r,c,l);return S(Zt(c,l,d,u),ae(c.direction,c.edge,d,a,o))}function Jt(e,n,r){Yt(e),t(r),i({amount:e,pixels:n})}function Yt(t){if(t!==void 0&&!Number.isFinite(t))throw new e(`INVALID_ARGS`,`scroll amount must be a number`)}async function Xt(e,t,n,r){if(n.edge){let i=n.edge,a=await se({edge:i,captureState:async n=>await Qt(e,t,i,n),scroll:async()=>await e.scroll(n.direction,r)});return{interactionResult:a.result??{},completedPasses:a.passes}}return{interactionResult:await e.scroll(n.direction,r)??{},completedPasses:1}}function Zt(e,t,n,r){let i=u(r);return{direction:e.direction,...e.edge?{edge:e.edge,passes:n}:{},...t.amount===void 0?{}:{amount:t.amount},...t.pixels===void 0?{}:{pixels:t.pixels},...i===void 0?{}:{durationMs:i},...r}}async function Qt(t,n,r,i){if(typeof t.snapshot!=`function`)throw new e(`UNSUPPORTED_OPERATION`,`scroll ${r} requires snapshot support to verify hidden content before scrolling`);let a=t.snapshot;return await ie({edge:r,scope:i,captureNodes:async e=>(await a({appBundleId:n?.appBundleId,scope:e})).nodes??[]})}function $t(e){return e===`bottom`?{direction:`down`,edge:`bottom`}:e===`top`?{direction:`up`,edge:`top`}:{direction:c(e)}}async function en(e,t,n){let{x:r,y:i}=K(t,`read requires x y`);if(e.platform===`android`){let{readAndroidTextAtPoint:t}=await import(`./input-actions.js`).then(e=>e.s);return{action:`read`,text:await t(e,r,i)??``}}if(e.platform===`linux`){let{readLinuxTextAtPoint:e}=await import(`./snapshot.js`).then(e=>e.n);return{action:`read`,text:await e(r,i,n?.surface)}}if(h(e)&&n?.surface&&n.surface!==`app`){let{runMacOsReadTextAction:e}=await import(`./helper.js`).then(e=>e.t);return{action:`read`,text:(await e(r,i,{bundleId:n.appBundleId,surface:n.surface})).text}}let{runAppleRunnerCommand:a}=await import(`./runner-client.js`).then(e=>e.o),o=await a(e,{command:`readText`,x:r,y:i,appBundleId:n?.appBundleId},{verbose:n?.verbose,logPath:n?.logPath,traceLogPath:n?.traceLogPath,requestId:n?.requestId,iosXctestrunFile:n?.iosXctestrunFile,iosXctestDerivedDataPath:n?.iosXctestDerivedDataPath,iosXctestEnvDir:n?.iosXctestEnvDir});return{action:`read`,text:typeof o.text==`string`?o.text:typeof o.message==`string`?o.message:``}}function tn(e){return de(e[0])}function J(e){return e.button&&e.button!==`primary`?`Clicked ${e.button} (${e.x}, ${e.y})`:`Tapped (${e.x}, ${e.y})`}function Y(e,t){return`${e} ${Array.from(t).length} chars`}function nn(e){let t=e.trim();return t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith(`[`)&&t.endsWith(`]`)}function X(t,n){let r=n?.subject??`Payload`,i=t.trim();if(!i)throw new e(`INVALID_ARGS`,`${r} cannot be empty`);let a=n?.expandPath?n.expandPath(i,n.cwd):i;try{if(!be.statSync(a).isFile())throw new e(`INVALID_ARGS`,`${r} path is not a file: ${a}`);return{kind:`file`,path:a}}catch(t){if(t instanceof e)throw t;let n=t.code;if(n===`EACCES`||n===`EPERM`)throw new e(`INVALID_ARGS`,`${r} file is not readable: ${a}`);if(n&&n!==`ENOENT`)throw new e(`COMMAND_FAILED`,`Unable to read ${r} file: ${a}`,{cause:String(t)})}if(nn(i))return{kind:`inline`,text:i};throw new e(`INVALID_ARGS`,`${r} file not found: ${a}`)}async function rn(t){let n=X(t,{subject:`Push payload`}),r=n.kind===`inline`?n.text:await an(n.path);try{let t=JSON.parse(r);if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`push payload must be a JSON object`);return t}catch(n){throw n instanceof e?n:new e(`INVALID_ARGS`,`Invalid push payload JSON: ${t}`)}}async function an(t){try{return await k.readFile(t,`utf8`)}catch(n){let r=n.code;throw r===`ENOENT`?new e(`INVALID_ARGS`,`Push payload file not found: ${t}`):r===`EISDIR`?new e(`INVALID_ARGS`,`Push payload path is not a file: ${t}`):r===`EACCES`||r===`EPERM`?new e(`INVALID_ARGS`,`Push payload file is not readable: ${t}`):new e(`COMMAND_FAILED`,`Unable to read push payload file: ${t}`,{cause:String(n)})}}D();async function Z(t,n){if(j(t)){let r=Ce(t,n);if(r)return r;throw new e(`UNSUPPORTED_OPERATION`,`Provider device runtime does not have an active interactor for this device.`,{deviceId:t.id,platform:g(t)})}return await ve(t.platform).createInteractor(t,n)}async function on(e,t,n,r,i){let a=Q(i),o=await Z(e,a);return w({level:`debug`,phase:`platform_command_prepare`,data:{command:t,platform:e.platform,kind:e.kind}}),await fe(`platform_command`,async()=>await un(e,o,t,n,r,i,a),{command:t,platform:e.platform})}async function sn(t,n,r){let i=await Z(t,Q(r));if(!i.performGesture)throw new e(`UNSUPPORTED_OPERATION`,`Gesture execution is unavailable`);return await i.performGesture(n)}async function cn(e,t){return await(await Z(e,Q(t))).gestureViewport?.()}function Q(e){return{requestId:e?.requestId,signal:e?.signal,appBundleId:e?.appBundleId,verbose:e?.verbose,logPath:e?.logPath,traceLogPath:e?.traceLogPath,iosXctestrunFile:e?.iosXctestrunFile,iosXctestDerivedDataPath:e?.iosXctestDerivedDataPath,iosXctestEnvDir:e?.iosXctestEnvDir,runnerLeaseContext:e?.runnerLeaseContext}}const ln={open:({device:e,interactor:t,positionals:n,context:r})=>dn(e,t,n,r),close:async({device:e,interactor:t,positionals:n})=>{let r=n[0];return r?(await t.close(r),{app:r,...x(`Closed: ${r}`)}):(e.platform===`web`&&await t.close(``),{closed:`session`,...x(`Closed session`)})},press:({device:e,interactor:t,positionals:n,context:r})=>Nt(e,t,n,r),longpress:({interactor:e,positionals:t})=>Ot(e,t),focus:({interactor:e,positionals:t})=>kt(e,t),type:({interactor:e,positionals:t,context:n})=>At(e,t,n),fill:({interactor:e,positionals:t,context:n})=>jt(e,t,n),scroll:({interactor:e,positionals:t,context:n})=>qt(e,t,n),"trigger-app-event":({device:e,interactor:t,positionals:n,context:r})=>fn(e,t,n,r),screenshot:({interactor:e,positionals:t,outPath:n,context:r})=>pn(e,t,n,r),viewport:({interactor:e,positionals:t})=>mn(e,t),back:async({interactor:e,context:t})=>(await e.back(t?.backMode),{action:`back`,mode:t?.backMode??`in-app`,...x(`Back`)}),home:async({interactor:e})=>(await e.home(),{action:`home`,...x(`Home`)}),orientation:async({interactor:e,positionals:t})=>{let n=ue(t[0]),r=(await e.setOrientation(n))?.orientation??n;return{action:`orientation`,orientation:r,...x(`Rotated to ${r}`)}},"app-switcher":async({interactor:e})=>(await e.appSwitcher(),{action:`app-switcher`,...x(`Opened app switcher`)}),clipboard:({interactor:e,positionals:t})=>hn(e,t),keyboard:({device:e,positionals:t,context:n,runnerCtx:r})=>_n(e,t,n,r),"tv-remote":({device:e,interactor:t,positionals:n,context:r})=>gn(e,t,n,r),settings:({device:e,interactor:t,positionals:n,context:r})=>xn(e,t,n,r),push:({device:e,positionals:t,context:n})=>Sn(e,t,n),snapshot:({interactor:e,context:t})=>Cn(e,t),read:({device:e,positionals:t,context:n})=>en(e,t,n)};async function un(t,n,r,i,a,o,s){let c=Object.hasOwn(ln,r)?ln[r]:void 0;if(!c)throw new e(`INVALID_ARGS`,`Unknown command: ${r}`);return await c({device:t,interactor:n,positionals:i,outPath:a,context:o,runnerCtx:s})}async function dn(t,n,r,i){let a=r[0],o=r[1],s=i?.launchConsole,c=i?.launchArgs;if(r.length>2)throw new e(`INVALID_ARGS`,`open accepts at most two arguments: <app|url> [url]`);if(!a){if(s)throw new e(`INVALID_ARGS`,`--launch-console requires an app target`);if(c&&c.length>0)throw new e(`INVALID_ARGS`,`--launch-args requires an app target`);return await n.openDevice(),{app:null,...x(`Opened device`)}}if(s&&(!v(t)||t.kind!==`simulator`))throw new e(`UNSUPPORTED_OPERATION`,re);if(t.platform===`linux`&&c&&c.length>0)throw new e(`UNSUPPORTED_OPERATION`,`--launch-args is not supported on Linux.`);if(o!==void 0){if(m(a))throw new e(`INVALID_ARGS`,`open <app> <url> requires an app target as the first argument`);if(!m(o))throw new e(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);if(s)throw new e(`INVALID_ARGS`,b);return await n.open(a,{activity:i?.activity,appBundleId:i?.appBundleId,launchArgs:c,terminateRunningApp:i?.terminateRunningApp,url:o}),{app:a,url:o,...x(`Opened: ${a}`)}}if(s&&m(a))throw new e(`INVALID_ARGS`,b);if(i?.clearAppState){if(m(a))throw new e(`INVALID_ARGS`,`Clearing app state requires an app target, not a deep link.`);await n.setSetting(`clear-app-state`,`clear`,a)}return await n.open(a,{activity:i?.activity,appBundleId:i?.appBundleId,launchConsole:s,launchArgs:c,terminateRunningApp:i?.terminateRunningApp}),{app:a,...s?{launchConsole:s}:{},...x(`Opened: ${a}`)}}async function fn(e,t,n,r){let{eventName:i,payload:a}=yt(n),o=bt(e,i,a);return await t.open(o,{appBundleId:r?.appBundleId}),{event:i,eventUrl:o,transport:`deep-link`,...x(`Triggered app event: ${i}`)}}async function pn(e,t,n,i){let a=t[0]??n??`./screenshot-${Date.now()}.png`;await k.mkdir(ye.dirname(a),{recursive:!0});let o=r(i);return await e.screenshot(a,{appBundleId:i?.appBundleId,pixelDensity:o.pixelDensity,fullscreen:o.fullscreen,normalizeStatusBar:o.normalizeStatusBar,stabilize:o.stabilize,surface:i?.surface,skipIosSimulatorBootCheck:i?.skipIosSimulatorBootCheck,captureBackend:i?.screenshotCaptureBackend}),{path:a,...x(`Saved screenshot: ${a}`)}}async function mn(t,n){if(n.length!==2)throw new e(`INVALID_ARGS`,`viewport requires exactly two arguments: <width> <height>`);let r=oe(n[0],`width`),i=oe(n[1],`height`);if(!t.setViewport)throw new e(`UNSUPPORTED_OPERATION`,`viewport is not supported by this backend`);return await t.setViewport(r,i),{width:r,height:i,...x(`Viewport set: ${r}x${i}`)}}async function hn(t,n){let r=(n[0]??``).toLowerCase();if(r!==`read`&&r!==`write`)throw new e(`INVALID_ARGS`,`clipboard requires a subcommand: read or write`);if(r===`read`){if(n.length!==1)throw new e(`INVALID_ARGS`,`clipboard read does not accept additional arguments`);return{action:r,text:await t.readClipboard()}}if(n.length<2)throw new e(`INVALID_ARGS`,`clipboard write requires text (use "" to clear clipboard)`);let i=n.slice(1).join(` `);return await t.writeClipboard(i),{action:r,textLength:Array.from(i).length,...x(`Clipboard updated`)}}async function gn(t,n,r,i){if(t.target!==`tv`)throw new e(`UNSUPPORTED_OPERATION`,`tv-remote is supported only on TV targets`,{hint:`Select an Android TV, tvOS, or Vega OS target with --target tv.`});if(r.length!==1)throw new e(`INVALID_ARGS`,`tv-remote requires exactly one button`);let o=a(r[0]),s=i?.durationMs===void 0?void 0:C(i.durationMs,`durationMs`,0,1e4);return await n.tvRemote(o,s),{action:`tv-remote`,button:o,...s===void 0?{}:{durationMs:s},...x(`Pressed TV remote ${o}`)}}async function _n(t,n,r,i){let a=(n[0]??`status`).toLowerCase();if(!ce(a))throw new e(`INVALID_ARGS`,`keyboard requires a subcommand: status, get, dismiss, enter, or return`);if(n.length>1)throw new e(`INVALID_ARGS`,`keyboard accepts at most one subcommand argument`);if(t.platform===`android`)return await vn(t,a);if(v(t))return await yn(t,a,r,i);throw new e(`UNSUPPORTED_OPERATION`,`keyboard is supported only on Android and iOS`)}async function vn(e,t){if(t===`enter`||t===`return`){let{pressAndroidEnter:t}=await import(`./input-actions.js`).then(e=>e.s);return await t(e),{platform:`android`,action:`enter`,...x(`Keyboard enter pressed`)}}if(t===`dismiss`){let{dismissAndroidKeyboard:t}=await import(`./device-input-state.js`).then(e=>e.t),n=await t(e);return{platform:`android`,action:`dismiss`,attempts:n.attempts,wasVisible:n.wasVisible,dismissed:n.dismissed,visible:n.visible,inputType:n.inputType,type:n.type,inputMethodPackage:n.inputMethodPackage,focusedPackage:n.focusedPackage,focusedResourceId:n.focusedResourceId,inputOwner:n.inputOwner}}let{getAndroidKeyboardState:n}=await import(`./device-input-state.js`).then(e=>e.t),r=await n(e);return{platform:`android`,action:`status`,visible:r.visible,inputType:r.inputType,type:r.type,inputMethodPackage:r.inputMethodPackage,focusedPackage:r.focusedPackage,focusedResourceId:r.focusedResourceId,inputOwner:r.inputOwner}}async function yn(t,n,r,i){if(n!==`dismiss`&&n!==`enter`&&n!==`return`)throw new e(`UNSUPPORTED_OPERATION`,`keyboard status/get is currently supported only on Android; use keyboard dismiss or enter on iOS`);if(n===`enter`||n===`return`){let{runAppleRunnerCommand:e}=await import(`./runner-client.js`).then(e=>e.o),n=await e(t,{command:`keyboardReturn`,appBundleId:r?.appBundleId},i);return{platform:`ios`,action:`enter`,visible:n.visible,wasVisible:n.wasVisible,...x(`Keyboard enter pressed`)}}let{runAppleRunnerCommand:a}=await import(`./runner-client.js`).then(e=>e.o),o=await a(t,{command:`keyboardDismiss`,appBundleId:r?.appBundleId},i),s=typeof o.keyboardDismissMechanism==`string`?o.keyboardDismissMechanism:void 0;return{platform:`ios`,action:`dismiss`,wasVisible:o.wasVisible,dismissed:o.dismissed,visible:o.visible,mechanism:s,...x(bn(o.dismissed===!0,s))}}function bn(e,t){return e?t===`dismissKey`?`Keyboard dismissed via its dismiss key`:`Keyboard dismissed`:`Keyboard already hidden`}async function xn(t,n,r,i){let[a,o,c,l]=r;if(!a||!o&&a!==`clear-app-state`)throw new e(`INVALID_ARGS`,`settings requires setting state`);if(a===`clear-app-state`){let r=(o===`clear`?c:o)??i?.appBundleId;if(!r)throw new e(`INVALID_ARGS`,`settings clear-app-state requires an app id or an active app session.`);w({level:`debug`,phase:`settings_apply`,data:{setting:a,state:`clear`,appBundleId:r,platform:t.platform}});let s=await n.setSetting(a,`clear`,r);return s&&typeof s==`object`?S({setting:a,state:`clear`,...s},$(s)??`Cleared user data for ${r}`):{setting:a,state:`clear`,...x(`Cleared user data for ${r}`)}}if(!o)throw new e(`INVALID_ARGS`,`settings requires setting state`);let u=a===`location`&&o===`set`,d=(a===`permission`||u?r[4]:r[2])??i?.appBundleId,f=a===`permission`?{permissionTarget:c,permissionMode:l}:u?{latitude:s(c,`latitude`),longitude:s(l,`longitude`)}:void 0;w({level:`debug`,phase:`settings_apply`,data:u?{setting:a,state:o,latitude:c,longitude:l,platform:t.platform}:a===`permission`?{setting:a,state:o,permissionTarget:c,permissionMode:l,platform:t.platform}:{setting:a,state:o,appBundleId:d,platform:t.platform}});let p=await n.setSetting(a,o,d,f);return p&&typeof p==`object`?S({setting:a,state:o,...p},$(p)??`Updated setting: ${a}`):{setting:a,state:o,...x(`Updated setting: ${a}`)}}async function Sn(t,n,r){let i=n[0]?.trim(),a=n[1]?.trim();if(!i||!a)throw new e(`INVALID_ARGS`,`push requires <bundle|package> <payload.json|inline-json>`);let o=await rn(a);if(v(t)){let{pushIosNotification:e}=await import(`./apps.js`).then(e=>e.t);return await e(t,i,o),{platform:`ios`,bundleId:i,...x(`Pushed notification to ${i}`)}}let{pushAndroidNotification:s}=await import(`./notifications.js`),c=await s(t,i,o);return{platform:`android`,package:i,action:c.action,extrasCount:c.extrasCount,...x(`Pushed notification to ${i}`)}}async function Cn(e,t){let n=t??{};return await e.snapshot({appBundleId:n.appBundleId,signal:n.signal,interactiveOnly:n.snapshotInteractiveOnly,preferredBackend:n.snapshotPreferredBackend,depth:n.snapshotDepth,scope:n.snapshotScope,raw:n.snapshotRaw,includeRects:n.snapshotIncludeRects,includeHiddenContentHints:n.snapshotIncludeHiddenContentHints,surface:n.surface})}function $(e){return typeof e.message==`string`&&e.message.length>0?e.message:void 0}function wn(e,t,r,i,a,o){return{requestId:a??pe().requestId,appBundleId:r,runnerLeaseContext:_e({meta:o}),activity:t?.activity,launchConsole:t?.launchConsole,launchArgs:t?.launchArgs,clearAppState:t?.clearAppState,verbose:t?.verbose,logPath:e,traceLogPath:i,iosXctestrunFile:t?.iosXctestrunFile,iosXctestDerivedDataPath:t?.iosXctestDerivedDataPath,iosXctestEnvDir:t?.iosXctestEnvDir,screenshotCaptureBackend:t?.maestro?.screenshotCaptureBackend,snapshotInteractiveOnly:t?.snapshotInteractiveOnly,snapshotPreferredBackend:t?.snapshotPreferredBackend,snapshotDepth:t?.snapshotDepth,snapshotScope:t?.snapshotScope,snapshotRaw:t?.snapshotRaw,snapshotIncludeHiddenContentHints:t?.snapshotIncludeHiddenContentHints,...n(t),count:t?.count,intervalMs:t?.intervalMs,delayMs:t?.delayMs,durationMs:t?.durationMs,holdMs:t?.holdMs,jitterPx:t?.jitterPx,pixels:t?.pixels,doubleTap:t?.doubleTap,clickButton:d(t),backMode:t?.backMode,pauseMs:t?.pauseMs,pattern:t?.pattern}}export{j as S,Ue as _,X as a,we as b,mt as c,ot as d,ct as f,ze as g,We as h,cn as i,ht as l,Be as m,on as n,ft as o,st as p,sn as r,pt as s,wn as t,it as u,Ee as v,Te as x,De as y};
|
package/dist/src/devices.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"node:os";function t(){return{platform:`apple`,id:`host-macos-local`,name:e.hostname(),kind:`device`,target:`desktop`,appleOs:`macos`,booted:!0}}async function n(){return[t()]}export{t as buildHostMacDevice,n as listMacosDevices};
|
package/dist/src/devices2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e}from"./sdk-contracts.js";import{b as t,s as n}from"./sdk-device.js";import{o as r}from"./boot-diagnostics.js";import{a as i,r as a}from"./tool-provider.js";import{I as o}from"./physical-device-control.js";import{r as s}from"./simulator.js";import{buildHostMacDevice as c}from"./devices.js";import l from"node:path";import{promises as u}from"node:fs";import d from"node:os";const f=/^(iphone|ipad|ipod|appletv|realitydevice)/i,p=/ipad/i,m=/\b(apple vision|vision pro|xros|visionos|realitydevice)\b/i,h=/\b(iphone|ipad|ipod)\b/i,g=/^appletv/i,_=[`apple tv`,`appletv`,`tvos`],v=/^==\s*(.+?)\s*==$/,y=/^(?<name>.+?)\s+(?:\[(?<idBracket>[^[\]]+)\]|\((?<osVersion>[^)]+)\)\s+\((?<idParen>[^)]+)\))\s*$/;function b(e){return(e??``).trim().toLowerCase()}function x(e){return b(e)}function S(e){return b(e.hardwareProperties?.platform)}function C(e){return e.includes(`tvos`)}function w(e){return e.includes(`xros`)||e.includes(`visionos`)}function T(e){return C(x(e))?`tv`:`mobile`}function E(e){let t=x(e);return t.includes(`ios`)||t.includes(`tvos`)||t.includes(`xros`)||t.includes(`visionos`)}function D(e){let t=b(e);return _.some(e=>t.includes(e))}function O(e){return h.test(e.trim())}function k(e){return D(e)?`tv`:O(e)||m.test(e)?`mobile`:null}function A(e,t){return e===`tv`?`tvos`:t.some(e=>m.test(e))?`visionos`:t.some(e=>p.test(e))?`ipados`:`ios`}function j(e){return f.test(e.trim())}function M(e){return g.test(e.trim())}function N(e){return[e.name??``,e.deviceProperties?.name??``,e.deviceProperties?.deviceType??``]}function P(e){return e.hardwareProperties?.productType??e.deviceProperties?.productType??``}function F(e){return C(S(e))||M(P(e))||N(e).some(D)?`tv`:`mobile`}function I(e){let t=S(e);return t.includes(`ios`)||t.includes(`tvos`)||w(t)||j(P(e))?!0:N(e).some(D)}async function L(e={}){let n=r(e.simulatorSetPath),a=e.target,s;try{s=await i(o([`list`,`devices`,`-j`],{simulatorSetPath:n}))}catch{return null}let c;try{c=JSON.parse(s.stdout)}catch{return null}return t(R(c,n)).find(e=>!a||e.target===a)??null}function R(e,t){let n=[];for(let[r,i]of Object.entries(e.devices))if(E(r))for(let e of i){if(!e.isAvailable)continue;let i=T(r),a={platform:`apple`,id:e.udid,name:e.name,kind:`simulator`,target:i,appleOs:A(i,[e.deviceTypeIdentifier??``,e.name]),booted:e.state===`Booted`,...t?{simulatorSetPath:t}:{}};a.booted&&s(a),n.push(a)}return n}function z(e){let t=[];for(let n of e.result?.devices??[]){if(!I(n))continue;let e=n.hardwareProperties?.udid??n.identifier??``,r=n.name??n.deviceProperties?.name??e;if(!e)continue;let i=F(n);t.push({platform:`apple`,id:e,name:r,kind:`device`,target:i,appleOs:A(i,[P(n),...N(n)]),iosPhysicalDeviceBackend:`coredevice`,booted:!0})}return t}function B(e){let t=y.exec(e);if(!t?.groups)return null;let n=t.groups.name?.trim()??``,r=t.groups.idBracket?.trim()??t.groups.idParen?.trim()??``,i=t.groups.osVersion?.trim();return!n||!r?null:{name:n,id:r,osVersion:i}}function V(e,t,n){let r=k(e);return r?{platform:`apple`,id:t,name:e,kind:`device`,target:r,appleOs:A(r,n?[e,n]:[e]),iosPhysicalDeviceBackend:`xctest`,booted:!0}:null}function H(e){let t=[],n=null;for(let r of e.split(/\r?\n/)){let e=r.trim();if(!e)continue;let i=v.exec(e);if(i){n=i[1]?.trim()??null;continue}if(n!==`Devices`)continue;let a=B(e);if(!a)continue;let o=V(a.name,a.id,a.osVersion);o&&t.push(o)}return t}function U(e,t){let n=new Set(e.map(e=>e.id)),r=[...e];for(let e of t)n.has(e.id)||(n.add(e.id),r.push(e));return r}async function W(){let e=null;try{if(e=l.join(d.tmpdir(),`agent-device-devicectl-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}.json`),(await i([`devicectl`,`list`,`devices`,`--json-output`,e],{allowFailure:!0,timeoutMs:8e3})).exitCode!==0)return[];let t=await u.readFile(e,`utf8`);return z(JSON.parse(t))}catch{return[]}finally{e&&await u.rm(e,{force:!0}).catch(()=>{})}}async function G(){try{let e=await i([`xctrace`,`list`,`devices`],{allowFailure:!0});return e.exitCode===0?H(e.stdout):[]}catch{return[]}}async function K(s={}){if(process.platform!==`darwin`)throw new e(`UNSUPPORTED_PLATFORM`,`Apple tools are only available on macOS`);if(!await a().whichCommand(`xcrun`))throw new e(`TOOL_MISSING`,`xcrun not found in PATH`);let l=r(s.simulatorSetPath),u=await i(o([`list`,`devices`,`-j`],{simulatorSetPath:l})),d=[];try{d=R(JSON.parse(u.stdout),l)}catch(t){throw new e(`COMMAND_FAILED`,`Failed to parse simctl devices JSON`,void 0,t)}if(d.push(c()),s.udid&&d.some(e=>n(e)&&e.id===s.udid))return d;if(l)return t(d);let[f,p]=await Promise.all([W(),G()]);return d=U(d,f),t(U(d,p))}export{L as findBootableIosSimulator,K as listAppleDevices};
|
package/dist/src/devices3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{hostname as e}from"node:os";async function t(){return process.platform===`linux`?[{platform:`linux`,id:`local`,name:e(),kind:`device`,target:`desktop`,booted:!0}]:[]}export{t as listLinuxDevices};
|
package/dist/src/devices4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e}from"./sdk-contracts.js";import{h as t}from"./sdk-android-adb.js";import{t as n}from"./tool-provider3.js";const r=`VirtualDevice`;async function i(){let r=n();if(!await r.isAvailable())throw new e(`TOOL_MISSING`,`Vega CLI not found in PATH`,{hint:`Install Vega Developer Tools, source ~/vega/env, and retry devices.`});let i=t(await r.listDevices({allowFailure:!0,timeoutMs:1e4}),`Failed to list Vega devices`),o=a(i.stdout),c=s(i.stdout);if(o.length===0&&c.length>0)throw new e(`DEVICE_NOT_FOUND`,`Vega CLI found devices, but no supported Vega Virtual Device is running.`,{listedSerials:c,hint:`Start the Vega Virtual Device, then retry with --platform vega --target tv.`});return o}function a(e){return s(e).some(o)?[{platform:`vega`,id:r,name:`Vega Virtual Device (${r})`,kind:`emulator`,target:`tv`,booted:!0}]:[]}function o(e){return e.toLowerCase()===`virtualdevice`}function s(e){let t=new Set;for(let n of e.split(/\r?\n/)){let e=/^\s*([^\s:]+)\s*:\s*\S/.exec(n)?.[1]?.trim();e&&t.add(e)}return[...t]}export{i as listVegaDevices,a as parseVegaDeviceList};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./png-worker-contract.js";import{_ as t}from"./sdk-contracts.js";import{p as n,v as r}from"./sdk-android-adb.js";import{n as i}from"./version.js";import{n as a,r as o}from"./src.js";import{n as s}from"./android.js";function c(){return{clientVersion:i(),android:{createInteractor:(e,t)=>s(e,t),createPortReverse:async e=>{let{createAndroidPortReverseManager:t}=await import(`./sdk-android-adb.js`).then(e=>e.t);return t(e)},inferAppName:async e=>{let{inferAndroidAppName:t}=await import(`./app-lifecycle.js`).then(e=>e.t);return t(e)},listApps:async(e,t)=>{let{listAndroidAppsWithAdb:n}=await import(`./app-helpers.js`).then(e=>e.t);return(await n(e,{filter:t,target:`mobile`})).map(e=>({id:e.package,name:e.name}))},getForegroundApp:async e=>{let{getAndroidAppStateWithAdb:t}=await import(`./app-helpers.js`).then(e=>e.t),n=await t(e);return n.package?{appId:n.package,activity:n.activity}:void 0},getKeyboardState:async e=>{let{getAndroidKeyboardStatusWithAdb:t}=await import(`./device-input-state.js`).then(e=>e.t);return await t(e)},dismissKeyboard:async e=>{let{dismissAndroidKeyboardWithAdb:t}=await import(`./device-input-state.js`).then(e=>e.t);return await t(e)},readLogs:async(e,t)=>{let{captureAndroidLogcatWithAdb:n}=await import(`./logcat.js`).then(e=>e.n);return await n(e,{lines:t,timeoutMs:5e3})},adbError:async(e,t,n)=>{let{androidAdbResultError:r}=await import(`./sdk-android-adb.js`).then(e=>e.t);return r(e,t,n)}},host:{runAdb:async(e,t)=>await r(`adb`,e,t),archiveDirectory:async({sourceDirectory:e,entryName:i,archivePath:a})=>{let o=[`-qr`,a,i],s=await r(`zip`,o,{cwd:e,timeoutMs:12e4});if(s.exitCode!==0)throw new t(`COMMAND_FAILED`,`Failed to package iOS .app for Limrun install`,{command:[`zip`,...o].join(` `),...n(s)})}},ios:{resolveAppAlias:async e=>{let{resolveIosAppAlias:t}=await import(`./app-resolution.js`).then(e=>e.t);return t(e)},readBundleAppName:async e=>{let{readIosBundleInfo:t}=await import(`./install-artifact2.js`).then(e=>e.t);return(await t(e)).appName}}}}var l=e({LimrunRuntime:()=>u}),u=class{implementation;provider=o;constructor(e){this.implementation=a(e,c())}get leaseLifecycle(){return this.implementation.leaseLifecycle}get recoverExpiredLease(){return this.implementation.recoverExpiredLease}get deviceInventoryProvider(){return this.implementation.deviceInventoryProvider}ownsDevice(e){return this.implementation.ownsDevice(e)}getInteractor(e){return this.implementation.getInteractor(e)}getDeviceSession(e){return this.implementation.getDeviceSession(e)}async installApp(e,t,n,r){return await this.implementation.installApp?.(e,t,n,r)}async installInstallablePath(e,t,n){return await this.implementation.installInstallablePath?.(e,t,n)}async configurePortReverse(e){return await this.implementation.configurePortReverse?.(e)}async shutdown(){await this.implementation.shutdown()}};export{l as n,u as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e}from"./sdk-contracts.js";import{c as t,f as n,o as r,y as i}from"./sdk-device.js";import{Kt as a}from"./viewport-dimension.js";import{l as o,o as s,p as c,s as l}from"./device.js";async function u(e){if(e.platform===`web`)return[l];if(o(e)){let{listMacosDevices:e}=await import(`./devices.js`);return await e()}if(e.platform===`linux`){let{listLinuxDevices:e}=await import(`./devices3.js`);return await e()}if(e.platform===`android`){let{listAndroidDevices:t}=await import(`./install-artifact.js`).then(e=>e.o);return await t({serialAllowlist:d(e)})}if(e.platform===`vega`){let{listVegaDevices:e}=await import(`./devices4.js`);return await e()}if(e.platform){let{listAppleDevices:t}=await import(`./devices2.js`);return await t({simulatorSetPath:e.iosSimulatorSetPath,udid:e.udid})}return(await Promise.all(s.map(async t=>{try{let n=await u({...e,platform:t});return Array.isArray(n)?n:[]}catch{return[]}}))).flat()}function d(e){let t=e.androidSerialAllowlist,n=e.serial?.trim();return n?t?new Set(t.includes(n)?[n]:[]):new Set([n]):t?new Set(t):void 0}const f=new Map;function p(e){for(let t of e.platforms){if(f.has(t))throw Error(`PlatformPlugin already registered for platform "${t}"`);f.set(t,e)}}function m(t){let n=f.get(t);if(!n)throw new e(`UNSUPPORTED_PLATFORM`,`Unsupported platform: ${t}`);return n}function h(e){return f.get(e)}const g={appAndDeviceLifecycle:!0,keyboard:!0,orientation:!0,physicalDeviceSurfaces:!1},_={ios:g,ipados:g,visionos:{appAndDeviceLifecycle:!0,keyboard:!0,orientation:!0,physicalDeviceSurfaces:!1},tvos:{appAndDeviceLifecycle:!0,keyboard:!1,orientation:!1,physicalDeviceSurfaces:!1},macos:{appAndDeviceLifecycle:!1,keyboard:!1,orientation:!1,physicalDeviceSurfaces:!0},watchos:{appAndDeviceLifecycle:!1,keyboard:!1,orientation:!1,physicalDeviceSurfaces:!1}};function v(e){return r(e.platform)?_[i(e)]:void 0}const y=e=>{let t=v(e);return t?t.appAndDeviceLifecycle:!0},b=e=>e.platform!==`apple`||e.kind!==`device`||e.iosPhysicalDeviceBackend!==`xctest`,x=e=>y(e)&&b(e),S=e=>{let t=v(e);return t?t.keyboard:e.platform===`android`},C=e=>{let t=v(e);return t?t.orientation:e.platform===`android`},w=e=>{let t=v(e);return t&&t.physicalDeviceSurfaces||e.kind===`simulator`},T=e=>e.platform===`android`||e.platform===`apple`&&i(e)===`ios`||w(e),E=e=>e.platform===`android`?e.target===`tv`:n(e),D={[a.boot]:y,[a.apps]:b,[a.install]:x,[a.reinstall]:x,[a.installFromSource]:x,[a.logs]:b,[a.perf]:b,[a.record]:b,[a.push]:y,[a.home]:y,[a.appSwitcher]:y,[a.clipboard]:e=>e.platform===`android`||e.platform===`linux`||w(e),[a.keyboard]:S,[a.orientation]:C,[a.tvRemote]:E,[a.alert]:T,[a.settings]:e=>e.platform===`android`||w(e),[a.audio]:c},O={[a.apps]:k,[a.install]:k,[a.reinstall]:k,[a.installFromSource]:k,[a.logs]:k,[a.perf]:k,[a.record]:k,[a.viewport]:e=>e.platform===`apple`?`viewport resizes web targets only (--platform web). Apple screen geometry is fixed by the selected simulator or device type — open a different simulator to test another screen size.`:void 0,[a.tvRemote]:e=>e.platform===`android`?e.target===`tv`?void 0:`tv-remote is supported only on Android TV targets.`:v(e)?n(e)?void 0:`tv-remote is supported only on tvOS devices.`:void 0};function k(e){if(!b(e))return`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`}const A={id:`apple`,platforms:[`apple`],familySelector:`apple`,capability:{bucket:`apple`,supportsByDefault:D,unsupportedHintByDefault:O},appLog:{resolveBackend:e=>t(e)?`macos`:e.kind===`device`?`ios-device`:`ios-simulator`},perf:{supportsMetrics:()=>!0,metricsSamplerTag:()=>`apple`},recording:{resolveBackendTag:e=>t(e)?`macos`:e.kind===`device`?`ios-device`:`ios-simulator`},providers:{platformGatedResolvers:[`appleRunnerProvider`,`appleToolProvider`]},createInteractor:async(e,t)=>{let{createAppleInteractor:n}=await import(`./interactor.js`);return n(e,t)},discoverDevices:async e=>{if(o(e)){let{listMacosDevices:e}=await import(`./devices.js`);return await e()}let{listAppleDevices:t}=await import(`./devices2.js`);return await t({simulatorSetPath:e.iosSimulatorSetPath,udid:e.udid})}},j=[a.open,a.close,a.back,a.home,a.tvRemote],M=e=>e.target===`tv`,N=e=>e.kind===`emulator`&&M(e),P={id:`vega`,platforms:[`vega`],capability:{bucket:`vega`,supportsByDefault:Object.fromEntries(j.map(e=>[e,M])),unsupportedHintByDefault:Object.fromEntries(j.map(e=>[e,t=>N(t)?void 0:`${e} currently supports only Vega Virtual Devices.`]))},providers:{platformGatedResolvers:[`vegaToolProvider`]},createInteractor:async(e,t)=>{let{createVegaInteractor:n}=await import(`./interactor2.js`);return n(e,t)},discoverDevices:async e=>{let{listVegaDevices:t}=await import(`./devices4.js`);return await t()}},F=[A,{id:`android`,platforms:[`android`],capability:{bucket:`android`,supportsByDefault:{[a.audio]:c,[a.tvRemote]:e=>e.target===`tv`},unsupportedHintByDefault:{[a.tvRemote]:e=>e.target===`tv`?void 0:`tv-remote is supported only on Android TV targets.`}},appLog:{resolveBackend:()=>`android`},perf:{supportsMetrics:()=>!0,metricsSamplerTag:()=>`android`},recording:{resolveBackendTag:()=>`android`},providers:{platformGatedResolvers:[`androidAdbProvider`]},createInteractor:async(e,t)=>{let{createAndroidInteractor:n}=await import(`./android.js`).then(e=>e.t);return n(e,void 0,t)},discoverDevices:async e=>{let{listAndroidDevices:t}=await import(`./install-artifact.js`).then(e=>e.o);return await t({serialAllowlist:d(e)})}},P,{id:`linux`,platforms:[`linux`],capability:{bucket:`linux`},providers:{platformGatedResolvers:[`linuxToolProvider`]},createInteractor:async()=>{let{createLinuxInteractor:e}=await import(`./linux.js`);return e()},discoverDevices:async()=>{let{listLinuxDevices:e}=await import(`./devices3.js`);return await e()}},{id:`web`,platforms:[`web`],capability:{bucket:`web`},recording:{resolveBackendTag:()=>`web`},providers:{platformGatedResolvers:[`webProvider`]},createInteractor:async()=>{let{createWebInteractor:e}=await import(`./web.js`);return e()},discoverDevices:async()=>[l]}];let I=!1;function L(){if(!I){for(let e of F)p(e);I=!0}}export{u as i,m as n,h as r,L as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./png-worker-contract.js";import{T as t,_ as n,v as r}from"./sdk-contracts.js";import{o as i,s as a}from"./sdk-device.js";import{D as o,I as s,j as c,y as l}from"./sdk-android-adb.js";import{n as u}from"./host-process.js";import{l as d,o as f,s as p}from"./boot-diagnostics.js";import{C as m,D as h,E as g,F as _,M as ee,O as te,S as v,T as y,_ as ne,a as b,b as x,c as re,d as ie,f as ae,g as oe,h as se,i as S,l as ce,m as le,n as ue,o as de,p as fe,r as pe,t as C,v as me,w as he,x as w,y as T}from"./runner-disposal.js";import{a as E,i as ge}from"./tool-provider.js";import{E as _e,L as ve,P as ye,S as be,T as xe,y as Se}from"./physical-device-control.js";import{a as Ce,d as we,f as D,n as Te,o as Ee,r as De,t as Oe,u as ke}from"./runner-lease.js";import{n as Ae,t as je}from"./runner-provider.js";import Me from"node:path";import Ne from"node:fs/promises";const Pe={tap:`preflightSkippableTouchMutation`,mouseClick:`default`,longPress:`preflightSkippableTouchMutation`,drag:`preflightSkippableTouchMutation`,remotePress:`default`,type:`default`,swipe:`preflightSkippableTouchMutation`,scroll:`preflightSkippableTouchMutation`,desktopScroll:`preflightSkippableTouchMutation`,findText:`readOnly`,querySelector:`readOnly`,readText:`readOnly`,snapshot:`readOnly`,screenshot:`readOnly`,back:`default`,backInApp:`default`,backSystem:`default`,home:`default`,rotate:`default`,gesture:`preflightSkippableTouchMutation`,gestureViewport:`readOnly`,appSwitcher:`default`,keyboardDismiss:`default`,keyboardReturn:`default`,alert:`readOnly`,sequence:`preflightSkippableTouchMutation`,recordStart:`default`,recordStop:`default`,status:`readOnlyReadinessProbe`,uptime:`readOnlyReadinessProbe`,activate:`readinessPreflightExemptMutation`,terminate:`readinessPreflightExemptMutation`,targetReset:`readinessPreflightExemptMutation`,shutdown:`default`},O={readOnly:!1,readinessProbe:!1,readinessPreflightExempt:!1,readinessPreflightSkipEligibleAfterHealthyMutation:!1},Fe={...O,readinessPreflightExempt:!0},Ie={...O,readOnly:!0},Le={...Ie,readinessProbe:!0},Re={...O,readinessPreflightSkipEligibleAfterHealthyMutation:!0},ze=Object.fromEntries(Object.entries(Pe).map(([e,t])=>[e,Ue(t)]));function k(e){return ze[e]}function A(e){return k(e).readOnly}function Be(e){return k(e).readinessProbe}function Ve(e){return k(e).readinessPreflightExempt}function He(e){return k(e).readinessPreflightSkipEligibleAfterHealthyMutation}function Ue(e){switch(e){case`default`:return O;case`readinessPreflightExemptMutation`:return Fe;case`readOnly`:return Ie;case`readOnlyReadinessProbe`:return Le;case`preflightSkippableTouchMutation`:return Re}}function We(e,t){return`${e}:${t}:${Date.now()}`}function Ge(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):void 0}function j(e=process.env){return o(e.AGENT_DEVICE_IOS_RUNNER_DETACH??``)!==!1}async function Ke(e,t){if(e.kind!==`simulator`||!j()||f(e.simulatorSetPath))return null;let n=Ee(e.id);if(!n)return null;let r=t=>(c({level:`debug`,phase:`ios_runner_lease_adoption_skipped`,data:{deviceId:e.id,runnerPid:n.runnerPid,port:n.port,reason:t}}),null),i=n.runnerPid;if(!i)return r(`runner_pid_missing`);if(!u(i))return r(`runner_process_dead`);if(!ke(n,i))return r(`runner_pid_recycled`);let a=Je(e);if(!a)return r(`expected_derived_unresolved`);if(!n.xctestrunPath.startsWith(`${a}${Me.sep}`))return r(`artifact_fingerprint_mismatch`);if(!await qe(e,n.port))return r(`probe_failed`);if(!u(i)||!ke(n,i))return r(`runner_pid_recycled`);let o=Ye(e,n,i,a,t);try{D(o.lease)}catch{return null}return c({level:`info`,phase:`ios_runner_lease_adopted`,data:{deviceId:e.id,sessionId:o.sessionId,runnerPid:i,port:n.port,previousOwnerPid:n.ownerPid}}),o}async function qe(e,t){try{let n=await oe(e,t,g({command:`uptime`}),500);return JSON.parse(await n.text())?.ok===!0}catch{return!1}}function Je(e){try{return xe(e,be(e))}catch{return null}}function Ye(e,t,n,r,i){let a=We(e.id,t.port),o={xctestrunPath:t.xctestrunPath,derived:r,cache:`exact`,artifact:`valid`,buildMs:0,xctestrunPathSource:`manifest`,reason:`adopted_from_lease`},{child:s,wait:c}=Xe(n);return{sessionId:a,device:e,deviceId:e.id,port:t.port,xctestrunPath:t.xctestrunPath,xctestrunArtifact:o,jsonPath:t.jsonPath,testPromise:c,child:s,ready:!0,startupTimeoutMs:Ge(i.startupTimeoutMs),lease:De({deviceId:e.id,sessionId:a,runnerPid:n,port:t.port,xctestrunPath:t.xctestrunPath,jsonPath:t.jsonPath})}}function Xe(e){let t={pid:e,exitCode:null};return{child:t,wait:new Promise(n=>{let r=setInterval(()=>{u(e)||(clearInterval(r),t.exitCode=-1,n({stdout:``,stderr:``,exitCode:-1}))},1e3);r.unref?.()})}}async function Ze(e){let t=await Qe(e.logPath)??et(e.error);return t?new n(t.code??e.error.code,e.error.message,{...e.error.details??{},hint:typeof e.error.details?.hint==`string`?`${e.error.details.hint} ${t.hint}`:t.hint,runnerFailureReason:t.reason},e.error):e.error}async function Qe(e){if(!e)return;let t=await it(e,65536);if(t)return $e(t)}function $e(e){let t=e.toLowerCase();if(tt(t))return{code:`IOS_TARGET_APP_CRASH`,reason:`target_app_axruntime_coretext_crash`,hint:`The target iOS app appears to have crashed while XCTest/AXRuntime read accessibility attributes. This is usually a simulator/XCTest/runtime or app accessibility payload issue, not a text-entry failure. Reproduce on the latest stable simulator runtime, reinstall the app, and capture the app crash from Console.app or ~/Library/Logs/DiagnosticReports with the exact command, selector/ref, app build, Xcode, and simulator runtime.`};if(nt(t))return{code:`IOS_TARGET_APP_CRASH`,reason:`target_app_crash`,hint:`The target iOS app appears to have crashed while the runner was executing the command. Reopen or reinstall the app, retry on a fresh/latest stable simulator runtime, and capture the app crash from Console.app or ~/Library/Logs/DiagnosticReports with the exact command, selector/ref, app build, Xcode, and simulator runtime.`}}function et(e){if(rt(e.message))return{reason:`runner_main_thread_execution_timeout`,hint:`XCTest timed out waiting for main-thread work on the current iOS screen. The app may still be visually responsive, especially on focused React Native overlays or animating screens. Use screenshot as visual truth, use coordinate presses only to prove or leave the state, and retry snapshot -i after the UI settles or after navigating away.`}}function tt(e){return e.includes(`axruntime`)&&e.includes(`coretext`)&&(e.includes(`attributesforelement`)||e.includes(`axuielementcopymultipleattributevalues`)||e.includes(`reconstitutedsmuggledctfontfromdictionary`)||e.includes(`reconstitutedsmuggledattributedstringfromdictionary`))}function nt(e){return e.includes(`process crashed`)||e.includes(`the application under test`)||e.includes(`terminated unexpectedly`)||e.includes(`exception type:`)&&e.includes(`thread 0 crashed`)}function rt(e){return e.toLowerCase().includes(`main thread execution timed out`)}async function it(e,t){let n;try{let r=await Ne.stat(e),i=Math.max(0,r.size-t),a=r.size-i;if(a<=0)return;n=await Ne.open(e,`r`);let o=Buffer.alloc(a);return await n.read(o,0,a,i),o.toString(`utf8`)}catch{return}finally{await n?.close().catch(()=>{})}}const M=new Map,at=new Map,N=new Map,P=1e4;function F(e,t){return h(at,e,t)}async function I(e,t){return z(e.id),await F(e.id,async()=>{let n=M.get(e.id);if(n){let t=await st(e,n);if(t)return t}return await we(e.id,async()=>await ot(e,t))})}async function ot(e,t){let n={},r=m(t),i=zt(t.runnerLeaseContext,e.id);c({level:`debug`,phase:`ios_runner_session_startup`,data:{deviceId:e.id,logicalLeaseContext:i}});let a=await H(n,`adopt_detached_runner`,async()=>await Ke(e,{startupTimeoutMs:t.startupTimeoutMs}));if(a)return a.startupTimings=n,a.logicalLeaseContext=i,M.set(e.id,a),a;await H(n,`cleanup_stale_xcodebuild`,async()=>{await Ce(e.id,de,i)}),await H(n,`ensure_booted`,async()=>{await _t(e)}),await H(n,`verify_developer_mode`,async()=>{await yt(e)}),t.cleanStaleBundles?await H(n,`cleanup_stale_bundles`,async()=>{await ct(e)}):(n.cleanup_stale_bundles=0,c({level:`debug`,phase:`ios_runner_startup_cleanup_stale_bundles_skipped`}));let o=await H(n,`ensure_xctestrun`,async()=>await ce(e,{...t,signal:r}));n.build_xctestrun=o.buildMs;let s=await H(n,`allocate_port`,async()=>await me()),{xctestrunPath:u,jsonPath:d}=await H(n,`prepare_xctestrun_env`,async()=>await ie(o.xctestrunPath,{AGENT_DEVICE_RUNNER_PORT:String(s)},`session-${e.id}-${Oe}-${s}`,{iosXctestEnvDir:t.iosXctestEnvDir})),f=await H(n,`simulator_set_redirect`,async()=>await fe(e)),p,h,g=[`test-without-building`,`-only-testing`,`AgentDeviceRunnerUITests/RunnerTests/testCommand`,`-parallel-testing-enabled`,`NO`,`-test-timeouts-enabled`,`NO`,`-collect-test-diagnostics`,`never`,_e(e),`1`,`-destination-timeout`,`20`,`-xctestrun`,u,`-derivedDataPath`,o.derived,`-destination`,ye(e)];try{o.buildMs>0&&te({type:`command`,status:`progress`,message:`Starting XCTest runner...`}),{child:p,wait:h}=await H(n,`launch_xcodebuild`,()=>l(`xcodebuild`,g,{allowFailure:!0,env:{...process.env,AGENT_DEVICE_RUNNER_PORT:String(s)},detached:!0,signal:r}))}catch(e){throw await f?.release(),e}p.stdout?.on(`data`,e=>{T(e,t.logPath,t.traceLogPath,t.verbose)}),p.stderr?.on(`data`,e=>{T(e,t.logPath,t.traceLogPath,t.verbose)});let _=We(e.id,s),v=De({deviceId:e.id,sessionId:_,runnerPid:p.pid,port:s,xctestrunPath:u,jsonPath:d}),y={sessionId:_,device:e,deviceId:e.id,port:s,xctestrunPath:u,xctestrunArtifact:o,jsonPath:d,testPromise:h,child:p,ready:!1,startupTimeoutMs:Ge(t.startupTimeoutMs),startupTimings:n,logicalLeaseContext:i,simulatorSetRedirect:f??void 0,lease:v};if(r?.aborted)throw await S(y,{graceful:!1,waitTimeoutMs:C}),ee();try{D(v)}catch(t){throw await R(e.id,y,{graceful:!1,waitTimeoutMs:C}),t}return M.set(e.id,y),y}async function st(e,t){if(!b(t.child.pid))return await H({},`stop_stale_session`,async()=>{await R(e.id,t,{graceful:!1,waitTimeoutMs:C})}),null;let n=t.xctestrunArtifact;if(n?.cache===`external`)return c({level:`debug`,phase:`ios_runner_session_reuse`,data:{deviceId:e.id,sessionId:t.sessionId,ready:t.ready,cache:n.cache,logicalLeaseContext:t.logicalLeaseContext}}),t;let r=xe(e,be(e));return n?.derived===r?(c({level:`debug`,phase:`ios_runner_session_reuse`,data:{deviceId:e.id,sessionId:t.sessionId,ready:t.ready,logicalLeaseContext:t.logicalLeaseContext}}),t):(c({level:`debug`,phase:`ios_runner_session_artifact_stale`,data:{deviceId:e.id,sessionId:t.sessionId,currentDerived:n?.derived,expectedDerived:r}}),await H({},`stop_stale_artifact_session`,async()=>{await R(e.id,t)}),null)}async function ct(e){if(e.kind===`simulator`)for(let t of Se){let n=await lt(e,t);!n||ut(n)}}async function lt(e,t){try{return await E(ve(e,[`uninstall`,e.id,t]),{allowFailure:!0,timeoutMs:P})}catch(n){c({level:`warn`,phase:`ios_runner_startup_cleanup_stale_bundle_failed`,data:{deviceId:e.id,bundleId:t,timeoutMs:P,error:n instanceof Error?n.message:String(n)}});return}}function ut(e){if(e.exitCode===0)return!0;let t=`${e.stdout}\n${e.stderr}`.toLowerCase();return t.includes(`not installed`)||t.includes(`found nothing`)||t.includes(`no such file`)||t.includes(`invalid device`)||t.includes(`could not find`)}function dt(e){let t=M.get(e);return t?{sessionId:t.sessionId,alive:b(t.child.pid)}:null}async function L(e,t){await F(e.deviceId,async()=>{M.get(e.deviceId)===e&&(c({level:`warn`,phase:`ios_runner_session_invalidated`,data:{deviceId:e.deviceId,sessionId:e.sessionId,reason:t}}),await R(e.deviceId,e,{graceful:!1,waitTimeoutMs:C}))})}async function R(e,t,n={}){let r=t??M.get(e);r&&(await S(r,n),M.get(e)===r&&M.delete(e))}function ft(e){z(e);let t=pt();if(t<=0||!M.has(e))return;let n=setTimeout(()=>{N.delete(e),c({level:`info`,phase:`ios_runner_idle_stop`,data:{deviceId:e,idleMs:t}}),B(e).catch(t=>{c({level:`warn`,phase:`ios_runner_idle_stop_failed`,data:{deviceId:e,error:t instanceof Error?t.message:String(t)}})})},t);n.unref?.(),N.set(e,n),c({level:`debug`,phase:`ios_runner_idle_stop_scheduled`,data:{deviceId:e,idleMs:t}})}function z(e){let t=N.get(e);t&&(clearTimeout(t),N.delete(e))}function pt(e=process.env){let t=e.AGENT_DEVICE_IOS_RUNNER_IDLE_STOP_MS?.trim();if(t){let e=Number(t);if(Number.isFinite(e)&&e>=0)return Math.floor(e)}return 3e5}async function B(e){z(e),await F(e,async()=>{await we(e,async()=>{await R(e),await pe(e)})})}async function mt(){let e=Array.from(M.values());await ue(e);for(let t of e)M.get(t.deviceId)===t&&M.delete(t.deviceId)}async function ht(){if(!j())return 0;let e=0;for(let[t,n]of M)if(n.device.kind===`simulator`&&!n.simulatorSetRedirect&&!(!n.lease||!b(n.child.pid))){try{D(Te(n.lease))}catch{continue}M.delete(t),z(t),e+=1,c({level:`info`,phase:`ios_runner_session_detached`,data:{deviceId:t,sessionId:n.sessionId,runnerPid:n.child.pid,port:n.port}})}return e}async function gt(){await mt();let e=Array.from(M.keys());await Promise.allSettled(e.map(async e=>{await B(e)})),await re()}function _t(e){return e.kind===`simulator`?e.booted?(c({level:`debug`,phase:`ios_runner_startup_ensure_booted_skipped`,data:{deviceId:e.id}}),Promise.resolve()):vt(e):Promise.resolve()}async function vt(e){await E(ve(e,[`bootstatus`,e.id,`-b`]),{timeoutMs:se})}async function yt(e){if(!a(e)||e.kind!==`device`)return;let t=await ge(`DevToolsSecurity`,[`-status`],{allowFailure:!0,timeoutMs:2e3}),r=`${t.stdout}\n${t.stderr}`;if(/developer mode is currently disabled/i.test(r))throw new n(`COMMAND_FAILED`,`Developer mode is disabled for Apple development tools`,{hint:"Run `sudo DevToolsSecurity -enable`, then retry the iOS runner. UI test runners start suspended until Xcode/testmanagerd can attach.",devToolsSecurityStatus:r.trim()})}function bt(e){if(!i(e.platform))throw new n(`UNSUPPORTED_PLATFORM`,`Unsupported platform for iOS runner: ${e.platform}`);if(e.kind!==`simulator`&&e.kind!==`device`)throw new n(`UNSUPPORTED_OPERATION`,`Unsupported iOS device kind for runner: ${e.kind}`)}async function V(e,t,n,r,i,a){Rt(t,n.command);let o=g(n),s=A(o.command),c=p.fromTimeoutMs(i),l=Pt(t,o);l.action===`run`?await wt({device:e,session:t,runnerCommand:o,logPath:r,deadline:c,signal:a,decision:l}):Tt(o,t,l);let u;try{u=await Ct({device:e,session:t,runnerCommand:o,logPath:r,deadline:c,timeoutMs:i,signal:a,readOnlyCommand:s})}catch(e){throw St(e,t,l)}try{let e=await Et(u,t,r),n=Nt(e);return n?(t.lastHealthyMutation=void 0,await L(t,n)):He(o.command)&&(t.lastHealthyMutation={atMs:Date.now(),appBundleId:o.appBundleId}),e}catch(e){let n=v(e);throw n?(t.lastHealthyMutation=void 0,await L(t,n),e):xt(e)?e:St(e,t,l)}}function xt(e){return e instanceof n&&e.details?.runner!==void 0}function St(e,t,n){return n.action!==`skip`||n.reason!==`recent_healthy_mutation`?e:(t.lastHealthyMutation=void 0,It(e,{runnerReadinessPreflightSkipped:!0,runnerReadinessPreflightSkipReason:n.reason,runnerReadinessPreflightSkippedAgeMs:n.lastHealthyMutationAgeMs}))}async function Ct(e){let{device:t,session:r,runnerCommand:i,logPath:a,deadline:o,timeoutMs:c,signal:l,readOnlyCommand:u}=e,d=o.remainingMs();if(d<=0)throw new n(`COMMAND_FAILED`,`Runner command deadline exceeded`,{timeoutMs:c});return await s(`ios_runner_command_send`,async()=>u?await ne(t,r.port,i,a,d,r,l):await oe(t,r.port,i,d,l),u?{command:i.command,commandId:i.commandId,readOnly:!0,sessionReady:r.ready,timeoutMs:d}:{command:i.command,commandId:i.commandId})}async function wt(e){let{device:t,session:n,runnerCommand:r,logPath:i,deadline:a,signal:o,decision:c}=e,l=n.ready?Math.min(1e3,a.remainingMs()):Math.min(Lt(n),a.remainingMs());try{await Et(await s(`ios_runner_readiness_preflight`,async()=>await ne(t,n.port,g({command:`uptime`}),i,l,n,o),{command:r.command,commandId:r.commandId,reason:c.reason,lastHealthyMutationAgeMs:c.lastHealthyMutationAgeMs,sessionReady:n.ready,timeoutMs:l}),n,i)}catch(e){throw Ft(e)}}function Tt(e,t,n){c({level:`debug`,phase:`ios_runner_readiness_preflight_skipped`,data:{command:e.command,commandId:e.commandId,reason:n.reason,lastHealthyMutationAgeMs:n.reason===`recent_healthy_mutation`?n.lastHealthyMutationAgeMs:void 0,sessionReady:t.ready}})}async function Et(e,t,n){let r=Dt(await e.text());if(!r.ok)throw await Ze({error:Ot(r,n),logPath:n});return t.ready=!0,jt(r)}function Dt(e){try{let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{throw new n(`COMMAND_FAILED`,`Invalid runner response`,{text:e})}}function Ot(e,t){let r=kt(e.error?.code),i=typeof e.error?.message==`string`?e.error.message:void 0,a=typeof e.error?.hint==`string`?e.error.hint:void 0;return new n(At(r),i??`Runner error`,{runner:e,runnerErrorCode:r,retriable:r===`RUNNER_BUSY`?!0:void 0,xcodebuild:{exitCode:1,stdout:``,stderr:``},hint:a,logPath:t})}function kt(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function At(e){return e===`RUNNER_BUSY`?`COMMAND_FAILED`:e?t(e):`COMMAND_FAILED`}function jt(e){if(!e.data||typeof e.data!=`object`||Array.isArray(e.data))return{};let t=e.data;return Mt(t),t}function Mt(e){let t=e.gestureFallback;typeof t!=`string`||t.length===0||c({level:`debug`,phase:`ios_runner_gesture_fallback`,data:{fallback:t,message:typeof e.gestureFallbackMessage==`string`?e.gestureFallbackMessage:void 0,hint:typeof e.gestureFallbackHint==`string`?e.gestureFallbackHint:void 0}})}function Nt(e){if(e.runnerFatal===!0)return typeof e.runnerFatalReason==`string`&&e.runnerFatalReason.trim().length>0?e.runnerFatalReason:`runner_reported_fatal_response`}function Pt(e,t){let n=A(t.command);if(Ve(t.command))return{action:`skip`,reason:`preflight_exempt_command`};if(!e.ready)return n?{action:`skip`,reason:`read_only_startup_command`}:{action:`run`,reason:`startup`};if(Be(t.command))return{action:`skip`,reason:`readiness_probe_command`};if(!He(t.command))return{action:`run`,reason:`conservative_command`};let r=e.lastHealthyMutation;if(!r)return{action:`run`,reason:`no_recent_healthy_mutation`};if(t.appBundleId!==r.appBundleId)return{action:`run`,reason:`app_activation_uncertain`};let i=Date.now()-r.atMs;return i>5e3?{action:`run`,reason:`healthy_mutation_stale`,lastHealthyMutationAgeMs:i}:{action:`skip`,reason:`recent_healthy_mutation`,lastHealthyMutationAgeMs:i}}function Ft(e){return It(e,{runnerReadinessPreflightFailed:!0})}function It(e,t){let r=e instanceof n?e:new n(`COMMAND_FAILED`,e instanceof Error?e.message:String(e),void 0,e);return new n(r.code,r.message,{...r.details??{},...t},r.cause??e)}function Lt(e){return e.startupTimeoutMs??45e3}async function H(e,t,n){let r=Date.now();try{return await n()}finally{let n=Date.now()-r;e[t]=n,c({level:`debug`,phase:`ios_runner_startup_${t}`,durationMs:n})}}function Rt(e,t){e.startupTimingsReported||!e.startupTimings||(e.startupTimingsReported=!0,c({level:`info`,phase:`ios_runner_session_startup_timings`,durationMs:Object.values(e.startupTimings).reduce((e,t)=>e+t,0),data:{command:t,sessionId:e.sessionId,ready:e.ready,logicalLeaseContext:e.logicalLeaseContext,timings:e.startupTimings}}))}function zt(e,t){if(!e)return;let n={leaseId:U(e.leaseId),clientId:U(e.clientId),tenantId:U(e.tenantId),runId:U(e.runId),leaseProvider:U(e.leaseProvider),deviceKey:U(e.deviceKey)??t},r=Object.entries(n).filter(([,e])=>e!==void 0);return r.length>0?Object.fromEntries(r):void 0}function U(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}async function Bt(e){let{device:t,session:n,command:r,transportError:i,options:a,signal:o,invalidationReason:s}=e;return await Vt(await Gt(t,n,r,i,a,o),{command:r,session:n,transportError:i,invalidationReason:s,invalidateSession:e.invalidateSession})}async function Vt(e,t){if(!e)return await Wt(t,`status_recovery_unavailable`);if(e.type===`recovered`)return Ht(e,t);if(e.type===`skipInvalidation`)throw Ut(e,t);return await Wt(t,e.reason,e.lifecycleState,e.error)}function Ht(e,t){return K({command:t.command,session:t.session,transportError:t.transportError,decision:`skipped`,reason:e.reason,lifecycleState:e.lifecycleState}),e.data}function Ut(e,t){return K({command:t.command,session:t.session,transportError:t.transportError,decision:`skipped`,reason:e.reason,lifecycleState:e.lifecycleState}),e.error}async function Wt(e,t,n,r){throw K({command:e.command,session:e.session,transportError:e.transportError,decision:`retained`,reason:t,lifecycleState:n}),await e.invalidateSession(e.session,e.invalidationReason),r??e.transportError}async function Gt(e,t,n,r,i,a){if(n.command===`status`||!n.commandId?.trim())return;let o=G(r),s;try{s=await V(e,t,{command:`status`,statusCommandId:n.commandId},i.logPath,3e3,a)}catch(e){return c({level:`debug`,phase:`ios_runner_command_status_recovery_failed`,data:{command:n.command,commandId:n.commandId,error:e instanceof Error?e.message:String(e),...o}}),{type:`retainInvalidation`,reason:`status_probe_failed`}}let l=typeof s.lifecycleState==`string`?s.lifecycleState:``;return c({level:`debug`,phase:`ios_runner_command_status_recovery`,data:{command:n.command,commandId:n.commandId,lifecycleState:l,...o}}),Kt(s,l,n,r,i)}function Kt(e,t,r,i,a){return t===`completed`?qt(e,r,i,a):t===`failed`?{type:`skipInvalidation`,reason:`runner_reported_failure`,lifecycleState:t,error:Jt(e,r,i,a)}:t===`accepted`||t===`started`?{type:`skipInvalidation`,reason:`command_still_in_flight`,lifecycleState:t,error:Yt(t,r,i,a)}:{type:`retainInvalidation`,reason:t?`unknown_lifecycle_state`:`missing_lifecycle_state`,lifecycleState:t,error:new n(`COMMAND_FAILED`,`Runner command "${r.command}" lost its transport response and lifecycle status was ${t?`"${t}"`:`missing`}, so agent-device invalidated the runner session instead of replaying the command.`,{command:r.command,commandId:r.commandId,lifecycleState:t,recovery:`lifecycle_state_not_recoverable`,hint:an(r.command),logPath:a.logPath,transportError:i.message},i)}}function qt(e,t,r,i){let a=Xt(e.lifecycleResponseJson);if(a)return{type:`recovered`,data:a,reason:`completed_with_retained_response`,lifecycleState:`completed`};if(A(t.command))return{type:`skipInvalidation`,error:r,reason:`read_only_completed_without_retained_response`,lifecycleState:`completed`};let o=G(r);return{type:`skipInvalidation`,reason:`completed_without_retained_response`,lifecycleState:`completed`,error:new n(`COMMAND_FAILED`,`Runner command "${t.command}" completed after the transport response was lost, but no recoverable response was retained.`,{command:t.command,commandId:t.commandId,lifecycleState:`completed`,recovery:`completed_without_retained_response`,...o,hint:Qt(t.command,o),logPath:i.logPath,transportError:r.message},r)}}function Jt(e,r,i,a){let o=typeof e.lifecycleErrorCode==`string`?e.lifecycleErrorCode:void 0,s=typeof e.lifecycleErrorMessage==`string`?e.lifecycleErrorMessage:`Runner command failed`,c=typeof e.lifecycleErrorHint==`string`?e.lifecycleErrorHint:void 0,l=G(i);return new n(t(o),s,{command:r.command,commandId:r.commandId,lifecycleState:`failed`,recovery:`runner_reported_failure`,...l,hint:c??$t(r.command,l),logPath:a.logPath,transportError:i.message},i)}function Yt(e,t,r,i){if(A(t.command))return r;let a=G(r);return new n(`COMMAND_FAILED`,`Runner command "${t.command}" is still ${e} after the transport response was lost.`,{command:t.command,commandId:t.commandId,lifecycleState:e,recovery:`command_still_in_flight`,...a,hint:en(t.command,e,a),logPath:i.logPath,transportError:r.message},r)}function Xt(e){if(typeof e!=`string`||e.trim().length===0)return;let t=Zt(e);if(t.ok)return t.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:{}}function Zt(e){try{let t=JSON.parse(e);if(t&&typeof t==`object`)return t}catch{}return{}}function Qt(e,t){return`${W(t)}The runner is still reachable and reports "${e}" already completed, so agent-device kept the session open and will not replay it. Run snapshot -i to inspect the current UI, then continue from that observed state.`}function $t(e,t){return`${W(t)}The runner is still reachable and reports "${e}" failed after the transport response was lost, so agent-device kept the session open and did not replay it. Run snapshot -i to inspect the current UI and retry with a selector visible in that snapshot.`}function en(e,t,n){return`${W(n)}The runner is still reachable and reports "${e}" is ${t}, so agent-device kept the session open and will not replay it. Wait briefly, run snapshot -i to inspect the current UI, then continue from that observed state.`}function W(e){return e.readinessPreflightSkipped===!0?`This hot command skipped the uptime preflight because the runner had just completed a healthy interaction; status recovery confirmed the runner still observed it. `:``}function tn(e,t){let n=e.details?.[t];return typeof n==`boolean`?n:void 0}function nn(e,t){let n=e.details?.[t];return typeof n==`string`?n:void 0}function rn(e,t){let n=e.details?.[t];return typeof n==`number`?n:void 0}function G(e){let t={},n=tn(e,`runnerReadinessPreflightSkipped`);n!==void 0&&(t.readinessPreflightSkipped=n);let r=nn(e,`runnerReadinessPreflightSkipReason`);r!==void 0&&(t.readinessPreflightSkipReason=r);let i=rn(e,`runnerReadinessPreflightSkippedAgeMs`);return i!==void 0&&(t.readinessPreflightSkippedAgeMs=i),t}function an(e){return`The runner did not confirm that "${e}" reached a safe terminal state, so agent-device kept the conservative invalidation path. Run snapshot -i before retrying if the UI may have changed.`}function K(e){let{command:t,session:n,transportError:r,decision:i,reason:a,lifecycleState:o}=e;c({level:i===`retained`?`warn`:`debug`,phase:`ios_runner_command_invalidation_decision`,data:{command:t.command,commandId:t.commandId,decision:i,reason:a,lifecycleState:o,runnerReachable:o!==void 0,sessionId:n.sessionId,transportError:r.message}})}const q=new Map;function on(e,t){let n=e.requestId?.trim();if(n)return`request:${n}`;let r=t.commandId?.trim();if(r)return`command:${r}`}function sn(e){if(!e)return;let t=J(e);t.touchedSession=!0,Y(e,t)}function cn(e){return e?q.get(e)?.touchedSession===!0:!1}function ln(e){if(!e)return!0;let t=J(e);return t.recycles>=1?(Y(e,t),!1):(Y(e,t),!0)}function un(e){if(!e)return;let t=J(e);t.recycles+=1,Y(e,t)}function dn(e,t){return c({level:`warn`,phase:`ios_runner_recycle_budget_exhausted`,data:{command:e.command,commandId:e.commandId,requestId:t.requestId,maxRecycles:1}}),new n(`COMMAND_FAILED`,`iOS runner was already restarted during this request and "${e.command}" still failed, so agent-device stopped instead of paying for another runner boot.`,{command:e.command,commandId:e.commandId,recovery:`runner_recycle_budget_exhausted`,hint:"Check the runner log for the underlying failure before retrying — a provisioning or code-signing error there means the runner cannot install on this device, and no retry will help. If the runner is healthy, the current screen is likely too heavy or animating for accessibility capture: the app session is preserved, so run `screenshot` for visual truth and interact by coordinates, or navigate to another screen.",logPath:t.logPath})}function J(e){return fn(),q.get(e)??{touchedSession:!1,recycles:0,lastAtMs:Date.now()}}function Y(e,t){t.lastAtMs=Date.now(),q.delete(e),q.set(e,t)}function fn(){let e=Date.now()-6e5;for(let[t,n]of q)n.lastAtMs<e&&q.delete(t);for(;q.size>512;){let e=q.keys().next().value;if(e===void 0)break;q.delete(e)}}async function pn(e,t){x(t.requestId);let r=m(t),i=g({command:`uptime`}),a;for(let n=1;n<=2;n+=1){let o=await mn({device:e,command:i,options:t,signal:r,attempt:n,recoveryReason:a});if(o.kind===`prepared`)return o.result;a=o.recoveryReason}throw new n(`COMMAND_FAILED`,`iOS runner prepare failed`)}async function mn(e){let{device:t,command:n,options:r,signal:i,attempt:a,recoveryReason:o}=e,s=Date.now(),c=await I(t,{...r,cleanStaleBundles:a>1?!0:r.cleanStaleBundles,...xn(r,`runner_session`)}),l=Date.now()-s;try{return{kind:`prepared`,result:Z(t,await bn(t,c,n,r,i,l,{recoveryReason:o}))}}catch(e){return await hn({device:t,session:c,command:n,options:r,signal:i,attempt:a,error:e})}}async function hn(e){let{device:t,session:n,command:i,options:a,signal:o,attempt:s,error:l}=e,u=r(l,`COMMAND_FAILED`);if(_(u))throw await X(n,`prepare_runner_request_canceled`),l;if(s===1&&Cn(u,n))return{kind:`prepared`,result:await gn({device:t,session:n,command:i,options:a,signal:o,error:u})};if(!_n(u))throw l;let d=u.message||`runner_health_failed`;if(s>=2)throw await X(n,`prepare_runner_health_failed`),l;return x(a.requestId),await L(n,`prepare_runner_health_retry`),c({level:`warn`,phase:`ios_runner_prepare_health_retry`,data:{command:i.command,commandId:i.commandId,sessionId:n.sessionId,attempt:s,maxAttempts:2,reason:d}}),{kind:`retry`,recoveryReason:d}}async function gn(e){let{device:t,session:n,command:r,options:i,signal:a,error:o}=e,s=o.message||`runner_health_failed`;await L(n,`prepare_cached_runner_health_failed`),await ae(n.xctestrunArtifact,s);let l=Date.now(),u=await I(t,{...i,cleanStaleBundles:!0,forceRunnerXctestrunRebuild:!0,...xn(i,`runner_rebuild`)}),d=Date.now()-l;try{let e=await bn(t,u,r,i,a,d,{recoveryReason:s});return c({level:`info`,phase:`ios_runner_prepare_bad_cache_recovered`,data:{command:r.command,commandId:r.commandId,sessionId:u.sessionId,xctestrunPath:u.xctestrunArtifact?.xctestrunPath,reason:s}}),Z(t,e)}catch(e){await X(u,`prepare_rebuilt_runner_health_failed`);let n=Tn(e,u,s);throw Dn(t,{cache:u.xctestrunArtifact?.cache,artifact:u.xctestrunArtifact?.artifact,buildMs:u.xctestrunArtifact?.buildMs,connectMs:d,healthCheckMs:0,xctestrunPath:u.xctestrunArtifact?.xctestrunPath,failureReason:n.message}),n}}async function X(e,t){try{await L(e,t)}catch{}}function _n(e){return _(e)?!1:w(e)||y(e)||wn(e)}async function vn(e,t,n){x(n.requestId);let i=m(n),a=on(n,t),o,s=!1;try{if(!dt(e.id)?.alive&&cn(a)){if(!ln(a))throw dn(t,n);s=!0}o=await I(e,n),s&&un(a),sn(a);let r=o.ready?le:Lt(o);return await V(e,o,t,n.logPath,r,i)}catch(a){let s=r(a,`COMMAND_FAILED`);if(o&&!o.ready&&_(s))throw await X(o,`runner_startup_request_canceled`),a;if(he(s)&&o)return x(n.requestId),await yn({device:e,session:o,command:t,options:n,signal:i,restartReason:`runner_connect_failed_before_command_send`});if(o&&kn(s))return x(n.requestId),await yn({device:e,session:o,command:t,options:n,signal:i,restartReason:`runner_readiness_preflight_failed_before_command_send`,recoveredDiagnosticPhase:`ios_runner_readiness_preflight_recovered`});if(o&&w(s))return await Bt({device:e,session:o,command:t,transportError:s,options:n,signal:i,invalidationReason:`transport_error_after_command_send`,invalidateSession:L});throw a}}async function yn(e){let{device:t,command:n,options:i,signal:a,restartReason:o}=e,s=on(i,n);if(!ln(s))throw dn(n,i);await L(e.session,o);let l=await I(t,{...i,cleanStaleBundles:!0});un(s);try{let r=await V(t,l,n,i.logPath,se,a);return e.recoveredDiagnosticPhase&&c({level:`debug`,phase:e.recoveredDiagnosticPhase,data:{command:n.command,commandId:n.commandId,recovery:`session_restarted`,sessionId:l.sessionId}}),r}catch(e){let o=r(e,`COMMAND_FAILED`);if(w(o))return await Bt({device:t,session:l,command:n,transportError:o,options:i,signal:a,invalidationReason:`transport_error_after_retry_command_send`,invalidateSession:L});throw e}}async function bn(e,t,n,r,i,a,o){let s=Date.now(),c=Sn(r.prepareDeadline,r.healthTimeoutMs,`runner_health`);return En(await V(e,t,n,r.logPath,c,i),t,a,Date.now()-s,o)}function xn(e,t){if(!e.prepareDeadline)return{};let n=Sn(e.prepareDeadline,e.buildTimeoutMs,t);return{buildTimeoutMs:n,startupTimeoutMs:n}}function Sn(e,t,r){if(!e)return t??45e3;let i=Math.floor(e.remainingMs());if(i<=0)throw new n(`COMMAND_FAILED`,`prepare ios-runner timed out`,{phase:r,reason:`prepare_deadline_expired`});return i}function Cn(e,t){let n=t.xctestrunArtifact;return!n||n.cache===`miss`?!1:_n(e)}function wn(e){let t=e.message.toLowerCase();return t.includes(`timeout`)||t.includes(`timed out`)||t.includes(`deadline`)}function Tn(e,t,i){let a=r(e,`COMMAND_FAILED`);return new n(a.code,`artifact restored but runner did not connect`,{...a.details??{},restoredFailureReason:i,xctestrunPath:t.xctestrunArtifact?.xctestrunPath,artifact:t.xctestrunArtifact?.artifact,cache:t.xctestrunArtifact?.cache,reason:a.message},a)}function En(e,t,n,r,i){let a=t.xctestrunArtifact,o={...i?.recoveryReason?{recoveryReason:i.recoveryReason}:{},...i?.failureReason?{failureReason:i.failureReason}:{}};return a?{runner:e,cache:a.cache,artifact:a.artifact,buildMs:a.buildMs,connectMs:Math.max(0,n),healthCheckMs:Math.max(0,r),xctestrunPath:a.xctestrunPath,...o}:{runner:e,connectMs:Math.max(0,n),healthCheckMs:Math.max(0,r),...o}}function Z(e,t){return Dn(e,t),t}function Dn(e,t){c({level:t.failureReason?`warn`:`info`,phase:`apple_runner_prepare`,data:{platform:e.platform,target:e.target,deviceId:e.id,cache:t.cache,artifact:t.artifact,buildMs:t.buildMs,connectMs:t.connectMs,healthCheckMs:t.healthCheckMs,timingContainment:t.buildMs===void 0?{healthCheckMs:[]}:{connectMs:[`buildMs`],healthCheckMs:[]},xctestrunPath:t.xctestrunPath,recoveryReason:t.recoveryReason,failureReason:t.failureReason}})}function On(e){return e.details?.runnerReadinessPreflightFailed===!0}function kn(e){return On(e)&&(w(e)||An(e))}function An(e){let t=e.message.toLowerCase();return t.includes(`timeout`)||t.includes(`timed out`)}var jn=e({detachIosSimulatorRunnerSessionsForShutdown:()=>ht,notifyIosRunnerAppRelaunched:()=>Mn,prepareIosRunner:()=>In,prewarmAppleRunnerCache:()=>Nn,prewarmIosRunnerSession:()=>Pn,runAppleRunnerCommand:()=>Q,stopAllIosRunnerSessions:()=>gt});async function Q(e,t,n={}){bt(e),x(n.requestId);let r=g(t),i=$(e,n);return A(r.command)?d(()=>(x(n.requestId),i.runCommand(e,r,n)),{shouldRetry:e=>(x(n.requestId),w(e))}):i.runCommand(e,r,n)}async function Mn(e,t={}){if(a(e))try{await Q(e,{command:`targetReset`},t)}catch(t){c({level:`warn`,phase:`ios_runner_target_reset_failed`,data:{deviceId:e.id,error:t instanceof Error?t.message:String(t)}}),await B(e.id)}}function Nn(e,t={}){if(a(e))return Fn({device:e,options:t,failurePhase:`ios_runner_cache_prewarm_failed`,task:async t=>{await ce(e,t)}})}function Pn(e,t={}){if(!a(e))return;let n=$(e,t).prewarm;if(!n){c({level:`debug`,phase:`ios_runner_session_prewarm_unavailable`,data:{deviceId:e.id}});return}return Fn({device:e,options:t,failurePhase:`ios_runner_session_prewarm_failed`,task:async t=>{await n(e,t)}})}function Fn(e){let{device:t,options:n,failurePhase:r,task:i}=e,{propagateError:a=!1,...o}=n;return i(o).catch(e=>{if(c({level:`warn`,phase:r,data:{deviceId:t.id,error:e instanceof Error?e.message:String(e)}}),a)throw e})}async function In(e,t){bt(e),x(t.requestId);let n=g({command:`uptime`}),r=$(e,t);if(r.prepare)return await r.prepare(e,t);let i=Date.now();return{runner:await r.runCommand(e,n,t),connectMs:0,healthCheckMs:Math.max(0,Date.now()-i)}}function $(e,t){return Ae(e,Ln,void 0,{requestId:t.requestId})}const Ln=je(vn,{prepare:pn,prewarm:async(e,t)=>{await pn(e,{...t,healthTimeoutMs:le})}});export{Q as a,ft as c,Pn as i,B as l,In as n,jn as o,Nn as r,dt as s,Mn as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./png-worker-contract.js";import{AsyncLocalStorage as t}from"node:async_hooks";var n=e({createLocalAppleRunnerProvider:()=>i,resolveAppleRunnerProvider:()=>a,withAppleRunnerProvider:()=>s});const r=new t;function i(e,t={}){return{runCommand:e,...t}}function a(e,t,n,r={}){if(n)return c(n);let i=o(e,r);return c(i?i.provider:t)}function o(e,t={}){let n=r.getStore();return n&&n.deviceId===e.id&&(n.requestId?n.requestId===t.requestId:!t.requestId)?n:void 0}async function s(e,t,n){if(!e)return await n();let i={provider:c(e),deviceId:t.deviceId,requestId:t.requestId};return await r.run(i,n)}function c(e){return typeof e==`function`?{runCommand:e}:e}export{s as i,a as n,n as r,i as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e}from"./sdk-contracts.js";import{Gt as t,Jt as n,Kt as r,Qt as i,Tn as a,Xt as o,Zt as s,dt as c,rn as l,sn as u}from"./sdk-batch-runner.js";const d={min:.01,max:1},f={flagKey:`screenshotMaxSize`,cliToken:`--max-size`,envVar:`AGENT_DEVICE_SCREENSHOT_MAX_SIZE`,publicOptionKey:`maxSize`,migration:{screenshot:`screenshot --max-size was removed; use --scale <0.01-1> (or AGENT_DEVICE_SCREENSHOT_SCALE) to downscale proportionally`,record:`record --max-size was removed; recordings capture at native resolution`}};function ee(e,t){return t&&Object.hasOwn(t,f.flagKey)?f.migration[e]:void 0}function te(t,n){if(Object.hasOwn(n,f.publicOptionKey)||Object.hasOwn(n,f.flagKey))throw new e(`INVALID_ARGS`,f.migration[t])}const ne=[`out`,`overlayRefs`,`screenshotPixelDensity`,`screenshotFullscreen`,`screenshotScale`,`screenshotNoStabilize`,`screenshotNormalizeStatusBar`],re=[`screenshotPixelDensity`,`screenshotFullscreen`,`screenshotScale`,`screenshotNoStabilize`,`screenshotNormalizeStatusBar`],ie=[{key:`screenshotPixelDensity`,names:[`--pixel-density`],type:`int`,min:1,usageLabel:`--pixel-density <n>`,usageDescription:`Screenshot: output PNG pixel density in pixels per logical point (currently supported on iOS simulators)`},{key:`screenshotFullscreen`,names:[`--fullscreen`,`--full`,`-f`],type:`boolean`,usageLabel:`--fullscreen, --full, -f`,usageDescription:`Screenshot: on web capture the full page; on macOS app sessions capture the full desktop instead of the app window`},{key:`screenshotScale`,names:[`--scale`],type:`number`,min:d.min,max:d.max,usageLabel:`--scale <0.01-1>`,usageDescription:`Screenshot: resize both dimensions by this factor (or use AGENT_DEVICE_SCREENSHOT_SCALE)`},{key:`screenshotNoStabilize`,names:[`--no-stabilize`],type:`boolean`,usageLabel:`--no-stabilize`,usageDescription:`Screenshot: skip Android demo-mode/status-bar stabilization and settle delay for low-latency capture loops`},{key:`screenshotNormalizeStatusBar`,names:[`--normalize-status-bar`],type:`boolean`,usageLabel:`--normalize-status-bar`,usageDescription:`Screenshot: on iOS simulators temporarily normalize status-bar chrome for deterministic screenshot diffs`}],ae=[{tokens:[`--fullscreen`,`--full`,`-f`],key:`screenshotFullscreen`},{tokens:[`--no-stabilize`],key:`screenshotNoStabilize`},{tokens:[`--normalize-status-bar`],key:`screenshotNormalizeStatusBar`}],oe=[{token:`--pixel-density`,key:`screenshotPixelDensity`,label:`screenshot --pixel-density`}],se=[{token:`--scale`,key:`screenshotScale`,label:`screenshot --scale`,min:d.min,max:d.max}];function ce(e){return p({overlayRefs:e?.overlayRefs,pixelDensity:e?.screenshotPixelDensity,fullscreen:e?.screenshotFullscreen,scale:e?.screenshotScale,stabilize:e?.screenshotNoStabilize?!1:void 0,normalizeStatusBar:e?.screenshotNormalizeStatusBar})}function le(e={}){return p({overlayRefs:e.overlayRefs,screenshotPixelDensity:e.screenshotPixelDensity??e.pixelDensity,screenshotFullscreen:e.screenshotFullscreen??e.fullscreen,screenshotScale:e.screenshotScale,screenshotNoStabilize:e.screenshotNoStabilize??(e.stabilize===!1?!0:void 0),screenshotNormalizeStatusBar:e.screenshotNormalizeStatusBar??e.normalizeStatusBar})}function ue(e={}){return le({...e,screenshotScale:e.screenshotScale??e.scale})}function de(t){let{min:n,max:r}=d;if(t.scale!==void 0&&(!Number.isFinite(t.scale)||t.scale<n||t.scale>r))throw new e(`INVALID_ARGS`,`screenshot scale must be between ${n} and ${r}`)}function fe(e,t){typeof t?.screenshotPixelDensity==`number`&&e.push(`--pixel-density`,String(t.screenshotPixelDensity)),t?.screenshotFullscreen&&e.push(`--fullscreen`),typeof t?.screenshotScale==`number`&&e.push(`--scale`,String(t.screenshotScale)),t?.screenshotNoStabilize&&e.push(`--no-stabilize`),t?.screenshotNormalizeStatusBar&&e.push(`--normalize-status-bar`)}function pe(t){let{args:n,flags:r,index:i}=t,a=n[i];if(a===f.cliToken)throw new e(`INVALID_ARGS`,f.migration.screenshot);return me(a,r,i)??he({args:n,index:i,flags:r,token:a})??ge({args:n,index:i,flags:r,token:a})??{handled:!1}}function p(e){return Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0))}function me(e,t,n){let r=ae.find(t=>t.tokens.some(t=>t===e));if(r)return t[r.key]=!0,{handled:!0,nextIndex:n}}function he(t){let n=oe.find(e=>e.token===t.token);if(!n)return;let r=Number(t.args[t.index+1]);if(!Number.isInteger(r)||r<1)throw new e(`INVALID_ARGS`,`${n.label} requires a positive integer`);return t.flags[n.key]=r,{handled:!0,nextIndex:t.index+1}}function ge(t){let n=se.find(e=>e.token===t.token);if(!n)return;let r=Number(t.args[t.index+1]);if(!Number.isFinite(r)||r<n.min||r>n.max)throw new e(`INVALID_ARGS`,`${n.label} requires a number from ${n.min} to ${n.max}`);return t.flags[n.key]=r,{handled:!0,nextIndex:t.index+1}}function _e(e){let t=ye(e.quality);return{...e.analysis?{analysis:e.analysis}:{},...e.androidSnapshot?{androidSnapshot:e.androidSnapshot}:{},...e.freshness?{freshness:e.freshness}:{},...t?{quality:t}:{},...e.warnings?{warnings:e.warnings}:{}}}function m(e){return{...e.androidSnapshot?{androidSnapshot:e.androidSnapshot}:{},...e.quality?{snapshotQuality:e.quality}:{},...e.warnings&&e.warnings.length>0?{warnings:e.warnings}:{}}}function ve(e){let t=be(e.androidSnapshot),n=Array.isArray(e.warnings)?e.warnings.filter(e=>typeof e==`string`):void 0,r=ye(e.snapshotQuality);return m({...t?{androidSnapshot:t}:{},...r?{quality:r}:{},...n?{warnings:n}:{}})}function ye(e){if(!e||typeof e!=`object`)return;let t=e;return typeof t.state==`string`&&typeof t.backend==`string`?t:void 0}function be(e){return typeof e==`object`&&e?e:void 0}const h=1500;function xe(e,t){e&&(e.snapshotDiagnostics??={samples:[]}).samples.push({...t,durationMs:Math.max(0,Math.round(t.durationMs))})}function Se(e){let t=e?.snapshotDiagnostics?.samples;if(!(!t||t.length===0))return Ce(t)}function Ce(e){if(e.length===0)return;let t=e.slice(1),n=t.length>=3?g(t):void 0,r=t.filter(e=>e.durationMs>=h).length,i=n!==void 0&&n.p95Ms>=h&&r>=2;return{stats:g(e),...i&&n?{warning:ke(n)}:{}}}function we(e){let t=e.filter(e=>e!==void 0),n=t.flatMap(e=>Fe(e.stats));if(n.length===0)return;let r=g(n),i=t.filter(e=>e.warning);return{stats:r,...i.length>0?{warning:Ae({warnedCount:i.length,totalCount:t.length,worst:i.reduce((e,t)=>Math.max(e,t.stats.p95Ms),0),platform:r.platform})}:{}}}function Te(e){if(!a(e))return;let t=je(e.stats);if(!t)return;let n=typeof e.warning==`string`?e.warning:void 0;return{stats:t,...n?{warning:n}:{}}}function g(e){let t=e.map(e=>e.durationMs).sort((e,t)=>e-t);return{count:t.length,p50Ms:Ee(t,50),p95Ms:Ee(t,95),maxMs:t[t.length-1]??0,slowThresholdMs:h,...De(e),...Oe(e)}}function Ee(e,t){if(e.length===0)return 0;let n=Math.max(0,Math.ceil(t/100*e.length)-1);return e[Math.min(n,e.length-1)]??0}function De(e){let t=e.map(e=>e.platform).filter(e=>!!e);return new Set(t).size===1?{platform:t[0]}:{}}function Oe(e){let t={};for(let n of e)n.backend&&(t[n.backend]=(t[n.backend]??0)+1);return Object.keys(t).length>0?{backends:t}:{}}function ke(e){return`Warning: ${e.platform?`${e.platform} `:``}snapshots are slow in this run: p95 ${e.p95Ms}ms over ${e.count} captures. Possible causes: device load, app or dev server stuck, helper fallback, or stale daemon.`}function Ae(e){return`Warning: ${e.platform?`${e.platform} `:``}snapshots were slow in ${e.warnedCount} of ${e.totalCount} runs (worst run p95 ${e.worst}ms). Possible causes: device load, app or dev server stuck, helper fallback, or stale daemon.`}function je(e){if(!a(e))return;let t=Me(e);if(t)return{...t,...Pe(e)}}function Me(e){let t={count:e.count,p50Ms:e.p50Ms,p95Ms:e.p95Ms,maxMs:e.maxMs,slowThresholdMs:e.slowThresholdMs};if(!Object.values(t).some(e=>typeof e!=`number`))return t}function Ne(e){let t=Object.entries(e).filter(e=>typeof e[1]==`number`);return t.length>0?Object.fromEntries(t):void 0}function Pe(e){let t=typeof e.platform==`string`?e.platform:void 0,n=a(e.backends)?Ne(e.backends):void 0;return{...t?{platform:t}:{},...n?{backends:n}:{}}}function Fe(e){if(!e||e.count<=0)return[];let t=e.platform;return e.count===1?[{durationMs:e.maxMs,platform:t}]:e.count===2?[{durationMs:e.p50Ms,platform:t},{durationMs:e.maxMs,platform:t}]:[...Array.from({length:e.count-3},()=>({durationMs:e.p50Ms,platform:t})),{durationMs:e.p50Ms,platform:t},{durationMs:e.p95Ms,platform:t},{durationMs:e.maxMs,platform:t}]}const Ie=1e4,Le=2e3,Re=[`get`,`accept`,`dismiss`,`wait`],ze=[`in-app`,`system`],Be=[`primary`,`secondary`,`middle`];function Ve(e){return e?.clickButton??`primary`}function He(t){return t.button===`primary`?null:t.commandLabel===`click`?t.platform!==`macos`&&t.platform!==`linux`?new e(`UNSUPPORTED_OPERATION`,`click --button ${t.button} is supported only on macOS and Linux`):t.platform===`macos`&&t.button===`middle`?new e(`UNSUPPORTED_OPERATION`,`click --button middle is not supported by the macOS runner yet`):typeof t.count==`number`||typeof t.intervalMs==`number`||typeof t.holdMs==`number`||typeof t.jitterPx==`number`||t.doubleTap===!0?new e(`INVALID_ARGS`,`click --button ${t.button} does not support repeat or gesture modifier flags`):null:new e(`INVALID_ARGS`,`--button is supported only for click`)}function Ue(e){return e===`primary`?{}:{button:e}}function We(t,n={message:e=>`Invalid value: ${e}`}){let r=new Set(t),i=n.normalize??(e=>e);return{is:e=>typeof e==`string`&&r.has(e),parse:t=>{let a=i(t??``);if(r.has(a))return a;throw new e(`INVALID_ARGS`,n.message(t??``))}}}const Ge=[`up`,`down`,`left`,`right`,`top`,`bottom`],_=[`up`,`down`,`left`,`right`],Ke=[`left`,`right`,`left-edge`,`right-edge`],qe=[`one-way`,`ping-pong`],Je=1e4,Ye=6e4,Xe=We(_,{message:e=>`Unknown direction: ${e}`});function Ze(e){let t=e.direction,n=t===`up`||t===`down`?e.referenceHeight:e.referenceWidth,r=x(e.amount),i=e.pixels===void 0?Math.round(n*r):S(e.pixels),a=Math.max(1,Math.round(n*.05)),o=Math.max(1,n-a*2),s=Math.max(1,Math.min(i,o)),c=Math.round(s/2),l=Math.round(e.referenceWidth/2),u=Math.round(e.referenceHeight/2),d=(n,r,i,a)=>({direction:t,x1:n,y1:r,x2:i,y2:a,referenceWidth:e.referenceWidth,referenceHeight:e.referenceHeight,amount:e.amount,pixels:s});switch(t){case`up`:return d(l,u-c,l,u+c);case`down`:return d(l,u+c,l,u-c);case`left`:return d(l-c,u,l+c,u);case`right`:return d(l+c,u,l-c,u)}}function Qe(e){x(e.amount),e.pixels!==void 0&&S(e.pixels)}function $e(e,t){if(e===`left`||e===`right`){let n=tt(e,t);return{preset:e,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,referenceWidth:n.referenceWidth,referenceHeight:n.referenceHeight}}let[n,r]=e===`left-edge`?[99,15]:[1,85],i=y(v(t,n,50),t,8),a=y(v(t,r,50),t,8);return{preset:e,x1:i.x,y1:i.y,x2:a.x,y2:a.y,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight}}function et(e,t){switch(e){case`up`:return{x:0,y:-t};case`down`:return{x:0,y:t};case`left`:return{x:-t,y:0};case`right`:return{x:t,y:0}}}function tt(e,t){let n=e===`left`||e===`up`,r=n?85:15,i=n?15:85,a=e===`up`||e===`down`,o=y(v(t,a?50:r,a?r:50),t,8),s=y(v(t,a?50:i,a?i:50),t,8);return{direction:e,x1:o.x,y1:o.y,x2:s.x,y2:s.y,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight}}function nt(e){let t=it(e);if(t)return{referenceWidth:t.width,referenceHeight:t.height}}function v(e,t,n){let r=Math.trunc(e.referenceWidth*t/100),i=Math.trunc(e.referenceHeight*n/100);return{x:Number.isFinite(r)?r:0,y:Number.isFinite(i)?i:0}}function y(e,t,n){return{x:at(e.x,n,t.referenceWidth),y:at(e.y,n,t.referenceHeight)}}function rt(e){return Xe.parse(e)}function it(e){let t=e.filter(e=>o(e)&&b(e.rect)).map(e=>e.rect).sort((e,t)=>(t?.width??0)*(t?.height??0)-(e?.width??0)*(e?.height??0))[0];if(t)return t;let n=e.map(e=>e.rect).filter(b);if(n.length===0)return;let r=Math.max(...n.map(e=>e.x+e.width)),i=Math.max(...n.map(e=>e.y+e.height));if(!(r<=0||i<=0))return{x:0,y:0,width:r,height:i}}function b(e){return!!e&&e.width>0&&e.height>0}function x(t){if(t===void 0)return .6;if(!Number.isFinite(t)||t<=0)throw new e(`INVALID_ARGS`,`scroll amount must be a positive number`);return t}function S(t){if(!Number.isFinite(t)||t<=0)throw new e(`INVALID_ARGS`,`scroll pixels must be a positive integer`);return Math.max(1,Math.round(t))}function at(e,t,n){let r=Math.round(t);if(!Number.isFinite(r))return 0;let i=Math.max(r,Math.round(n-t));return!Number.isFinite(i)||!Number.isFinite(e)?r:Math.min(i,Math.max(r,Math.round(e)))}const C=1e4,ot=[`pan`,`fling`,`swipe`,`pinch`,`rotate`,`transform`,`drag`];function w(t){let n=E(t),r=k(n,`kind`,ot);if(r===`pan`)return{kind:r,origin:D(n,`origin`),delta:D(n,`delta`),pointerCount:c(n,`pointerCount`,{min:1,max:2}),durationMs:T(n)};if(r===`drag`)return st(n);if(n.pointerCount!==void 0)throw new e(`INVALID_ARGS`,`pointerCount is supported only for gesture pan`);if(r===`fling`){if(n.durationMs!==void 0)throw new e(`INVALID_ARGS`,`gesture fling does not accept durationMs; use gesture pan for timed movement`);return{kind:r,direction:k(n,`direction`,_),origin:D(n,`origin`),distance:c(n,`distance`,{min:0})}}if(r===`swipe`){if(n.durationMs!==void 0)throw new e(`INVALID_ARGS`,`gesture swipe does not accept durationMs; use gesture pan for timed movement`);return{kind:r,preset:k(n,`preset`,Ke)}}if(r===`pinch`)return{kind:r,scale:O(n,`scale`),origin:ct(n,`origin`)};if(r===`rotate`){if(n.velocity!==void 0)throw new e(`INVALID_ARGS`,`gesture rotate does not accept velocity; rotation pacing derives from degrees`);return{kind:r,degrees:O(n,`degrees`),origin:ct(n,`origin`)}}return{kind:r,origin:D(n,`origin`),delta:D(n,`delta`),scale:O(n,`scale`),degrees:O(n,`degrees`),durationMs:T(n)}}function st(t){let n=c(t,`sourceHoldMs`,{min:1,max:1e4}),r=c(t,`moveMs`,{min:16,max:1e4}),i=c(t,`destinationHoldMs`,{min:0,max:1e4});if((n??800)+(r??500)+(i??0)>1e4)throw new e(`INVALID_ARGS`,`gesture drag total duration must be at most ${C}`);return{kind:`drag`,source:lt(t,`source`),destination:lt(t,`destination`),sourceHoldMs:n,moveMs:r,destinationHoldMs:i}}function T(t){let n=c(t,`durationMs`);if(n!==void 0){if(n<16||n>1e4)throw new e(`INVALID_ARGS`,`Expected durationMs to be an integer between 16 and ${C}.`);return n}}function E(t){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`gesture requires structured object input`);return t}function D(e,t){let n=E(e[t]);return{x:O(n,`x`),y:O(n,`y`)}}function ct(e,t){return e[t]===void 0?void 0:D(e,t)}function O(t,n){let r=t[n];if(typeof r!=`number`||!Number.isFinite(r))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);return r}function lt(t,n){let r=t[n];if(typeof r!=`string`||r.trim().length===0)throw new e(`INVALID_ARGS`,`Expected ${n} to be a non-empty string.`);return r.trim()}function k(t,n,r){let i=t[n];if(typeof i!=`string`||!r.includes(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be one of: ${r.join(`, `)}.`);return i}const ut={swipe:{max:4,usage:`swipe accepts 4 arguments: x1 y1 x2 y2`,retired:{positional:`durationMs`,migrate:dt}},"gesture pan":{max:5,usage:`gesture pan accepts at most 5 arguments: x y dx dy [durationMs]`},"gesture fling":{max:4,usage:`gesture fling accepts at most 4 arguments: direction x y [distance]`,retired:{positional:`durationMs`,migrate:(e,t)=>`use "${t}", or gesture pan for timed movement.`}},"gesture swipe":{max:1,usage:`gesture swipe accepts 1 argument: preset`,retired:{positional:`durationMs`,migrate:(e,t)=>`use "${t}", or gesture pan for timed movement.`}},"gesture pinch":{max:3,usage:`gesture pinch accepts at most 3 arguments: scale [x] [y]`},"gesture rotate":{max:3,usage:`gesture rotate accepts at most 3 arguments: degrees [x] [y]`,retired:{positional:`velocity`,migrate:(e,t)=>`use "${t}"; rotation pacing derives from degrees.`}},"gesture transform":{max:7,usage:`gesture transform accepts at most 7 arguments: x y dx dy scale degrees [durationMs]`},"gesture drag":{max:5,usage:`gesture drag accepts at most 5 arguments: source destination [sourceHoldMs] [moveMs] [destinationHoldMs]`}};function dt(e,t){let[n,r,i,a,o]=e,s=ft(n,i),c=ft(r,a);return s===void 0||c===void 0?`use "gesture pan x1 y1 dx dy durationMs" for the same timed drag, or "${t}" for a default-duration swipe.`:`use "gesture pan ${n} ${r} ${s} ${c} ${o}" for the same timed drag, or "${t}" for a default-duration swipe.`}function ft(e,t){let n=Number(t)-Number(e);return Number.isFinite(n)?n:void 0}function A(e,t){let n=ut[e];if(t.length<=n.max)return;let r=n.retired;if(!r||t.length!==n.max+1||!pt(t[n.max]))return{usage:n.usage};let i=`${e} ${t.slice(0,n.max).join(` `)}`;return{usage:n.usage,migration:`The trailing ${r.positional} positional was removed: ${r.migrate(t,i)}`}}function pt(e){return e===void 0||e.trim().length===0?!1:e.startsWith("${")||Number.isFinite(Number(e))}function mt(t){if(!(!t||typeof t!=`object`||Array.isArray(t))&&t.durationMs!==void 0)throw new e(`INVALID_ARGS`,`swipe does not accept durationMs; use gesture pan for timed movement`)}function j(e,t){let n=t?`${e.usage} (${t})`:e.usage;return e.migration?`${n}. ${e.migration}`:`${n}.`}function M(t,n){let r=A(t,n);if(r)throw new e(`INVALID_ARGS`,j(r))}function ht(e,t,n){let r=gt(e,t);return r?j(r,n):void 0}function gt(e,t){if(e===`swipe`)return A(`swipe`,t);if(e!==`gesture`)return;let n=`gesture ${t[0]}`;if(Object.hasOwn(ut,n))return A(n,t.slice(1))}function N(e){return{origin:{x:Number(e[0]),y:Number(e[1])},delta:{x:Number(e[2]),y:Number(e[3])}}}function P(e,t){let n=e[0],r=e.slice(1);switch(n){case`pan`:{M(`gesture pan`,r);let{origin:e,delta:i}=N(r);return w({kind:n,origin:e,delta:i,pointerCount:t,durationMs:F(r[4])})}case`fling`:return M(`gesture fling`,r),w({kind:n,direction:r[0],origin:{x:Number(r[1]),y:Number(r[2])},distance:F(r[3])});case`swipe`:return M(`gesture swipe`,r),w({kind:n,preset:r[0]});case`pinch`:return M(`gesture pinch`,r),w({kind:n,scale:Number(r[0]),origin:I(r[1],r[2])});case`rotate`:return M(`gesture rotate`,r),w({kind:n,degrees:Number(r[0]),origin:I(r[1],r[2])});case`transform`:{M(`gesture transform`,r);let{origin:e,delta:t}=N(r);return w({kind:n,origin:e,delta:t,scale:Number(r[4]),degrees:Number(r[5]),durationMs:F(r[6])})}case`drag`:return M(`gesture drag`,r),w({kind:n,source:r[0],destination:r[1],sourceHoldMs:F(r[2]),moveMs:F(r[3]),destinationHoldMs:F(r[4])});default:return w({kind:n})}}function _t(e){if(e[0]!==`drag`)return;let t=P(e);return t.kind===`drag`?t:void 0}function vt(e){switch(e.kind){case`pan`:return L([e.kind,e.origin.x,e.origin.y,e.delta.x,e.delta.y,e.durationMs]);case`fling`:return L([e.kind,e.direction,e.origin.x,e.origin.y,e.distance]);case`swipe`:return[e.kind,e.preset];case`pinch`:return L([e.kind,e.scale,e.origin?.x,e.origin?.y]);case`rotate`:return e.origin?L([e.kind,e.degrees,e.origin.x,e.origin.y]):[e.kind,String(e.degrees)];case`transform`:return L([e.kind,e.origin.x,e.origin.y,e.delta.x,e.delta.y,e.scale,e.degrees,e.durationMs]);case`drag`:return[e.kind,e.source,e.destination,String(e.sourceHoldMs??800),String(e.moveMs??500),String(e.destinationHoldMs??0)]}}function yt(e,t={}){return M(`swipe`,e),{from:{x:Number(e[0]),y:Number(e[1])},to:{x:Number(e[2]),y:Number(e[3])},...t.count===void 0?{}:{count:t.count},...t.pauseMs===void 0?{}:{pauseMs:t.pauseMs},...t.pattern===void 0?{}:{pattern:t.pattern}}}function bt(t){switch(t.kind){case`pan`:return{gesture:{intent:`pan`,origin:t.origin,delta:t.delta,pointerCount:t.pointerCount,durationMs:t.durationMs}};case`fling`:return{gesture:{intent:`fling`,direction:t.direction,origin:t.origin,distance:t.distance}};case`swipe`:return{gesture:{intent:`fling`,preset:t.preset}};case`pinch`:return{gesture:{intent:`pinch`,origin:t.origin,scale:t.scale}};case`rotate`:return{gesture:{intent:`rotate`,origin:t.origin,degrees:t.degrees}};case`transform`:return{gesture:{intent:`transform`,origin:t.origin,delta:t.delta,scale:t.scale,degrees:t.degrees,durationMs:t.durationMs}};case`drag`:throw new e(`INVALID_ARGS`,`gesture drag targets must be resolved before coordinate normalization`)}}function xt(e){return e.kind===`drag`?{intent:`drag`,source:e.source,destination:e.destination,sourceHoldMs:e.sourceHoldMs,moveMs:e.moveMs,destinationHoldMs:e.destinationHoldMs}:bt(e).gesture}function St(e){return{gesture:{intent:`fling`,from:e.from,to:e.to}}}function F(e){return e===void 0?void 0:Number(e)}function I(t,n){if(t===void 0!=(n===void 0))throw new e(`INVALID_ARGS`,`gesture origin requires both x and y coordinates`);return t===void 0?void 0:{x:Number(t),y:Number(n)}}function L(e){return e.filter(e=>e!==void 0).map(String)}const R={pinchAxisDegrees:-90,samplingProfile:`default`},Ct={ios:R,macos:R,android:{pinchAxisDegrees:0,samplingProfile:`android`},vega:R,linux:R,web:R};function wt(e,t,n){let r=Pt(t),i=Ht(n);switch(e.intent){case`fling`:return Ot(e,r);case`pan`:return kt(e,r,i);case`pinch`:return B({intent:`pinch`,origin:e.origin??zt(r),delta:{x:0,y:0},scale:Lt(e.scale,`gesture pinch scale`),rotationDegrees:0,durationMs:300},r,i);case`rotate`:{let t=K(e.degrees,`gesture rotate degrees`);return B({intent:`rotate`,origin:e.origin??zt(r),delta:{x:0,y:0},scale:1,rotationDegrees:t,durationMs:W(t)},r,i)}case`transform`:{let t=K(e.degrees,`gesture transform degrees`);return B({intent:`transform`,origin:e.origin,delta:e.delta,scale:Lt(e.scale,`gesture transform scale`),rotationDegrees:t,durationMs:U(e.durationMs,W(t),`gesture transform durationMs`)},r,i)}}}function Tt(e){let[{samples:t}]=e.pointers,n=t[0],r=t.at(-1);return{start:n.point,end:r.point}}function Et(t,n){let r=Pt(n),i=Ft(t.sourceHoldMs,800,`gesture drag sourceHoldMs`),a=U(t.moveMs,500,`gesture drag moveMs`),o=It(t.destinationHoldMs,0,`gesture drag destinationHoldMs`);if(i+a+o>1e4)throw new e(`INVALID_ARGS`,`gesture drag total duration must be at most ${C}`);return Dt(z(`pan`,t.from,t.to,a,r,`timed-pan`),i,o)}function Dt(e,t,n){let r=e.pointers[0],[i,a]=r.samples,o=t+e.durationMs+n,s=[{offsetMs:0,point:i.point},{...i,offsetMs:i.offsetMs+t},{...a,offsetMs:a.offsetMs+t},...n>0?[{offsetMs:o,point:a.point}]:[]];return{...e,durationMs:o,pointers:[{...r,samples:s}]}}function Ot(e,t){if(`preset`in e){let{from:n,to:r}=Vt(e.preset,t);return z(`fling`,n,r,100,t,`endpoint-hold`)}if(`from`in e)return z(`fling`,e.from,e.to,100,t,`endpoint-hold`);let n=G(e.origin,`gesture fling origin`),r=Rt(e.distance??180,`gesture fling distance`);return z(`fling`,n,q(n,et(e.direction,r)),100,t,`endpoint-hold`)}function kt(t,n,r){let i=U(t.durationMs,500,`gesture pan durationMs`);if((t.pointerCount??1)===1){let e=G(t.origin,`gesture pan origin`);return z(`pan`,e,q(e,G(t.delta,`gesture pan delta`)),i,n,t.executionProfile??`timed-pan`)}if(t.pointerCount!==2)throw new e(`INVALID_ARGS`,`gesture pan pointerCount must be 1 or 2`);return B({intent:`pan`,origin:t.origin,delta:t.delta,scale:1,rotationDegrees:0,durationMs:i},n,r)}function z(e,t,n,r,i,a){let o=G(t,`gesture ${e} start`),s=G(n,`gesture ${e} end`),c=[{offsetMs:0,point:o},{offsetMs:r,point:s}];return H(c,i,{intent:e,pointerId:0}),{topology:`single`,intent:e,executionProfile:a,durationMs:r,viewport:i,pointers:[{pointerId:0,samples:c}]}}function B(e,t,n){let r=G(e.origin,`gesture ${e.intent} origin`),i=q(r,G(e.delta,`gesture ${e.intent} delta`)),a=Math.min(t.width,t.height)*Mt(e.intent),o=e.scale>1?a/e.scale:a,s=o*e.scale;if(Math.min(o,s)<48)throw Nt({intent:e.intent,viewport:t,initialSpan:o,finalSpan:s,minimumReliableSpan:48});let c=o/2,l=V(e.durationMs,n.samplingProfile),u=(a,o)=>{let s=l.map(t=>({offsetMs:t,point:At({...e,start:r,end:i,initialRadius:c,offsetMs:t,side:o,profile:n})}));return H(s,t,{intent:e.intent,pointerId:a}),{pointerId:a,samples:s}};return{topology:`two`,intent:e.intent,durationMs:e.durationMs,viewport:t,pointers:[u(0,1),u(1,-1)]}}function At(e){let t=e.offsetMs/e.durationMs,n=Bt(e.start,e.end,t),r=e.initialRadius*(1+(e.scale-1)*t),i=Ut(jt(e.intent,e.profile)+e.rotationDegrees*t);return{x:n.x+Math.cos(i)*r*e.side,y:n.y+Math.sin(i)*r*e.side}}function jt(e,t){return e===`pinch`?t.pinchAxisDegrees:-90}function Mt(e){return e===`pinch`?.4:.25}function V(t,n){if(!Number.isFinite(t)||t<=0)throw new e(`INVALID_ARGS`,`gesture sample duration must be a positive finite number`);let r=t/16,i=Math.max(3,n===`android`?Math.round(r):Math.floor(r));return Array.from({length:i+1},(e,n)=>Math.round(t*n/i))}function H(t,n,r){let i=n.x+n.width-1,a=n.y+n.height-1;for(let o of t){let{x:t,y:s}=o.point;if(!Number.isFinite(t)||!Number.isFinite(s))throw new e(`INVALID_ARGS`,`Gesture motion produces non-finite pointer coordinates`,{...r,reason:`GESTURE_TRAJECTORY_NON_FINITE`,hint:`Reduce the requested rotation, translation, or scale.`});if(t<n.x+1||t>i||s<n.y+1||s>a)throw Nt({...r,viewport:n,sample:o})}}function Nt(t){return new e(`INVALID_ARGS`,`Gesture trajectory does not fit inside the viewport`,{...t,reason:`GESTURE_TRAJECTORY_OUT_OF_BOUNDS`,hint:`Move the gesture away from the edge or reduce its translation, scale, or rotation.`})}function Pt(t){let n={x:K(t.x,`gesture viewport x`),y:K(t.y,`gesture viewport y`),width:K(t.width,`gesture viewport width`),height:K(t.height,`gesture viewport height`)};if(n.width<=0||n.height<=0)throw new e(`INVALID_ARGS`,`gesture viewport width and height must be positive`);return n}function U(t,n,r){let i=t??n;if(!Number.isInteger(i)||i<16||i>1e4)throw new e(`INVALID_ARGS`,`${r} must be an integer between 16 and ${C}`);return i}function Ft(t,n,r){let i=t??n;if(!Number.isInteger(i)||i<1||i>1e4)throw new e(`INVALID_ARGS`,`${r} must be an integer between 1 and ${C}`);return i}function It(t,n,r){let i=t??n;if(!Number.isInteger(i)||i<0||i>1e4)throw new e(`INVALID_ARGS`,`${r} must be an integer between 0 and ${C}`);return i}function W(e){let t=Math.ceil(Math.abs(e)/3)*16;return Math.min(Math.max(300,t),2400)}function G(e,t){return{x:K(e.x,`${t} x`),y:K(e.y,`${t} y`)}}function K(t,n){if(!Number.isFinite(t))throw new e(`INVALID_ARGS`,`${n} must be a finite number`);return t}function Lt(t,n){let r=K(t,n);if(r<=0)throw new e(`INVALID_ARGS`,`${n} must be greater than 0`);return r}function Rt(t,n){let r=K(t,n);if(r<=0)throw new e(`INVALID_ARGS`,`${n} must be a positive number`);return r}function zt(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function q(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Bt(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Vt(e,t){let n=$e(e,{referenceWidth:t.width,referenceHeight:t.height});return{from:{x:t.x+n.x1,y:t.y+n.y1},to:{x:t.x+n.x2,y:t.y+n.y2}}}function Ht(e){return e===void 0?R:Ct[e]}function Ut(e){return e*Math.PI/180}const Wt={occlusion:{kind:`runtime`,via:`src/snapshot/snapshot-occlusion.ts#isSnapshotNodeInteractionBlocked`},offscreen:{kind:`runtime`,via:`src/commands/interaction/runtime/resolution.ts#throwIfOffscreenInteractionTarget`},nonHittable:{kind:`runtime`,via:`src/core/interaction-targeting.ts#resolveActionableTouchResolution`},responseConstruction:{kind:`runtime`,via:`src/daemon/handlers/interaction-touch-response.ts#buildInteractionResponseData`},responseIdentity:{kind:`runtime`,via:`src/daemon/handlers/interaction-touch-targets.ts#interactionResultExtra`},verifyEvidence:{kind:`runtime`,via:`src/commands/interaction/runtime/interactions.ts#pressCommand`,appliesTo:[`press`,`click`,`fill`]},settleObservation:{kind:`runtime`,via:`src/commands/interaction/runtime/settle.ts#settleAfterInteraction`}};({...Wt}),{...Wt};const Gt=`tapped via non-hittable coordinate fallback`,Kt=[`xctest-element`,`synthesized-first-responder`,`synthesized-first-responder-replacement`,`xctest-application-fallback`],qt=1e4;function Jt(t,n=`scroll accepts either a relative amount or --pixels, not both`){if(t.amount!==void 0&&t.pixels!==void 0)throw new e(`INVALID_ARGS`,n)}function Yt(t,n={}){if(t===void 0)return;let r=n.field??`scroll durationMs`,i=n.max??1e4,a=n.invalidMessage??`${r} must be a non-negative integer`;if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new e(`INVALID_ARGS`,a);if(t>i)throw new e(`INVALID_ARGS`,`${r} must be a non-negative integer at most ${i}`);return t}function Xt(e){return typeof e?.durationMs==`number`?e.durationMs:void 0}const Zt={android:`longpress`,apple:`exact`,vega:`exact`},J={up:{aliases:[],androidKeyevent:`KEYCODE_DPAD_UP`,appleRemoteButton:`up`,vegaKey:`KEY_UP`},down:{aliases:[],androidKeyevent:`KEYCODE_DPAD_DOWN`,appleRemoteButton:`down`,vegaKey:`KEY_DOWN`},left:{aliases:[],androidKeyevent:`KEYCODE_DPAD_LEFT`,appleRemoteButton:`left`,vegaKey:`KEY_LEFT`},right:{aliases:[],androidKeyevent:`KEYCODE_DPAD_RIGHT`,appleRemoteButton:`right`,vegaKey:`KEY_RIGHT`},select:{aliases:[`ok`,`center`,`enter`],androidKeyevent:`KEYCODE_DPAD_CENTER`,appleRemoteButton:`select`,vegaKey:`KEY_ENTER`},menu:{aliases:[],androidKeyevent:`KEYCODE_MENU`,appleRemoteButton:`menu`,vegaKey:`KEY_MENU`},home:{aliases:[],androidKeyevent:`KEYCODE_HOME`,appleRemoteButton:`home`,vegaKey:`KEY_HOMEPAGE`},back:{aliases:[],androidKeyevent:`KEYCODE_BACK`,appleRemoteButton:`menu`,vegaKey:`KEY_BACK`}},Y=Object.keys(J),Qt=`<${Y.join(`|`)}>`;function $t(t){let n=t?.toLowerCase();if(en(n))return n;let r=n?on.get(n):void 0;if(r)return r;throw new e(`INVALID_ARGS`,`tv-remote button must be one of: ${Y.join(`, `)}.`)}function en(e){return typeof e==`string`&&Y.includes(e)}function tn(e){return J[e].appleRemoteButton}function nn(e){return J[e].androidKeyevent}function rn(e){return J[e].vegaKey}function an(e){return Zt[e]}const on=new Map(Y.flatMap(e=>J[e].aliases.map(t=>[t,e]))),sn={captureStalled:`wait_capture_stalled`,deadlineExceeded:`wait_deadline_exceeded`,targetAbsent:`wait_target_absent`,stableTimeout:`wait_stable_timeout`,landmarkIdentityMismatch:`wait_landmark_identity_mismatch`},cn=[`camera`,`microphone`,`photos`,`contacts`,`contacts-limited`,`notifications`,`calendar`,`location`,`location-always`,`media-library`,`motion`,`reminders`,`siri`],ln=`<wifi|airplane|location> <on|off>`,un=`location set <lat> <lon>`,dn=`animations <on|off>`,X=`appearance <light|dark|toggle>`,fn=`faceid <match|nonmatch|enroll|unenroll>`,pn=`touchid <match|nonmatch|enroll|unenroll>`,mn=`fingerprint <match|nonmatch>`,hn=`clear-app-state [app-id]`,gn=`permission <grant|deny|reset> <camera|microphone|photos|contacts|contacts-limited|notifications|calendar|location|location-always|media-library|motion|reminders|siri> [full|limited]`,Z=`permission <grant|reset> <accessibility|screen-recording|input-monitoring>`,_n=`macOS supports only settings ${X} and settings ${Z}. wifi|airplane|location|animations remain unsupported on macOS.`,vn=[`settings ${ln}`,`settings ${un}`,`settings ${dn}`,`settings ${X}`,`settings ${fn}`,`settings ${pn}`,`settings ${mn}`,`settings ${hn}`,`settings ${gn}`,`settings ${Z}`].join(` | `),yn=`settings requires ${ln}, ${un}, ${dn}, ${X}, ${fn}, ${pn}, ${mn}, ${hn}, ${gn}, or ${Z}`;function bn(e){let t=e.trim().toLowerCase();return t===`appearance`||t===`permission`}function xn(e){return`Unsupported macOS setting: ${e}. ${_n}`}function Sn(t){let n=t.trim().toLowerCase();if(n===`grant`)return`grant`;if(n===`deny`)return`deny`;if(n===`reset`)return`reset`;throw new e(`INVALID_ARGS`,`Invalid permission action: ${t}. Use grant|deny|reset.`)}function Cn(t){let n=t?.trim().toLowerCase();if(n===`camera`||n===`microphone`||n===`photos`||n===`contacts`||n===`contacts-limited`||n===`notifications`||n===`calendar`||n===`location`||n===`location-always`||n===`media-library`||n===`motion`||n===`reminders`||n===`siri`)return n;throw new e(`INVALID_ARGS`,`permission setting requires a target: ${cn.join(`|`)}`)}function wn(t,n){if(t===void 0||t.trim()===``)throw new e(`INVALID_ARGS`,`settings location set requires ${n}`);return Q(Number(t),n)}function Tn(e){return{latitude:Q(e?.latitude,`latitude`),longitude:Q(e?.longitude,`longitude`)}}function Q(t,n){let r=n===`latitude`?-90:-180,i=n===`latitude`?90:180;if(typeof t!=`number`||!Number.isFinite(t)||t<r||t>i)throw new e(`INVALID_ARGS`,`${n} must be a number from ${r} to ${i}`);return t}function En(e){let t=new Map;for(let[n,r]of e.entries())t.set(r.index,n);let n=[],r=[];for(let[i,a]of e.entries()){let e=Math.max(0,a.depth??0);for(;r.length>0&&e<=r[r.length-1].depth;)r.pop();let o=i,s=typeof a.parentIndex==`number`?t.get(a.parentIndex):void 0,c=typeof s==`number`&&s<o?s:r[r.length-1]?.index;n.push({...a,index:o,depth:e,parentIndex:c}),r.push({depth:e,index:o})}return n}function $(e){return e.label?.trim()||e.value?.trim()||e.identifier?.trim()||``}function Dn(e){let t=e.trim().toLowerCase();return t?/^(vertical|horizontal)\s+scroll\s+bar(?:,?\s*\d+\s+pages?)?$/.test(t):!1}function On(e,t){if(!(e?.trim().toLowerCase()??``).includes(`vertical scroll bar`))return null;let n=kn(t);return n===null?null:n<=1?{above:!1,below:!0}:n>=99?{above:!0,below:!1}:{above:!0,below:!0}}function kn(e){if(!e)return null;let t=/^(\d{1,3})%$/.exec(e.trim());if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?Math.max(0,Math.min(100,n)):null}function An(e){if(e.length===0)return{nodes:e,hiddenCount:0,summaryLines:[]};let{byIndex:t,visibleNodeIndexes:n,offscreenNodes:r,hintedContainers:i}=Mn(e),a=n.size===0?e:e.filter(e=>n.has(e.index));return{nodes:a.map(e=>Rn(e,i.directionsByContainer)),hiddenCount:n.size===0?0:e.length-a.length,summaryLines:zn(r.filter(e=>!i.coveredNodeIndexes.has(e.index)&&Hn(e)),e,t)}}function jn(e){if(e.length===0)return new Map;let{hintedContainers:t}=Mn(e);return Ln(t.directionsByContainer)}function Mn(e){let t=u(e),n=new Set,i=[];for(let a of e){if(r(a,e,t)){Wn(a,n,t);continue}i.push(a)}return{byIndex:t,visibleNodeIndexes:n,offscreenNodes:i,hintedContainers:In(e,i,n,t)}}function Nn(e,t){return e.hittable&&n(e.rect,t)}function Pn(e,t,r=u(t)){if(!e.rect)return null;let a=s(e,t,r);if(a&&!l(e.rect,a)){let t=Fn(e.rect,a);if(t)return t}let o=i(t,e.rect);if(o&&!n(e.rect,o)){let t=Fn(e.rect,o);if(t)return t}return null}function Fn(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=[{direction:`down`,amount:r-(t.y+t.height)},{direction:`up`,amount:t.y-r},{direction:`right`,amount:n-(t.x+t.width)},{direction:`left`,amount:t.x-n}],a=null;for(let e of i)e.amount>0&&(!a||e.amount>a.amount)&&(a=e);return a?.direction??null}function In(e,t,n,r){let i=new Map,a=new Map,o=new Set;for(let e of t){if(!e.rect)continue;let t=Gn(e,n,r);if(!t?.rect)continue;let s=Vn(e.rect,t.rect);if(!s)continue;let c=i.get(t.index)??new Set;c.add(s),i.set(t.index,c);let l=a.get(t.index)??new Set;l.add(s),a.set(t.index,l),o.add(e.index)}return Kn(e,n,r,i,a),{directionsByContainer:i,coveredNodeIndexes:o}}function Ln(e){let t=new Map;for(let[n,r]of e){let e={};r.has(`above`)&&(e.hiddenContentAbove=!0),r.has(`below`)&&(e.hiddenContentBelow=!0),(e.hiddenContentAbove||e.hiddenContentBelow)&&t.set(n,e)}return t}function Rn(e,t){let n=t.get(e.index);if(!n||n.size===0)return e;let r=e.hiddenContentAbove===!0||n.has(`above`)?!0:void 0,i=e.hiddenContentBelow===!0||n.has(`below`)?!0:void 0;return{...e,hiddenContentAbove:r,hiddenContentBelow:i}}function zn(e,t,n){let r=new Map;for(let i of e){let e=Bn(i,t,n);if(!e)continue;let a=r.get(e)??[];a.push(i),r.set(e,a)}return[`above`,`below`].flatMap(e=>{let t=r.get(e);if(!t||t.length===0)return[];let n=Un(t).slice(0,3).map(e=>`"${e}"`),i=t.length===1?`interactive item`:`interactive items`,a=n.length>0?`: ${n.join(`, `)}`:``;return[`[off-screen ${e}] ${t.length} ${i}${a}`]})}function Bn(e,t,n){if(!e.rect)return null;let r=s(e,t,n);return r?Vn(e.rect,r):null}function Vn(e,t){return e.y+e.height<=t.y?`above`:e.y>=t.y+t.height?`below`:null}function Hn(e){if(e.hittable===!0)return!0;let t=(e.type??``).toLowerCase();return t.includes(`button`)||t.includes(`link`)||t.includes(`textfield`)||t.includes(`edittext`)||t.includes(`searchfield`)||t.includes(`checkbox`)||t.includes(`radio`)||t.includes(`switch`)||t.includes(`menuitem`)||!!$(e)}function Un(e){let t=new Set,n=[];for(let r of e){let e=$(r);!e||t.has(e)||(t.add(e),n.push(e))}return n}function Wn(e,t,n){let r=e,i=new Set;for(;r&&!i.has(r.index);)i.add(r.index),t.add(r.index),r=typeof r.parentIndex==`number`?n.get(r.parentIndex):void 0}function Gn(e,n,r){return t(e,r,e=>n.has(e.index))}function Kn(e,t,n,r,i){for(let a of e){let e=qn(a);if(!e||e.size===0)continue;let o=Gn(a,t,n);if(!o)continue;let s=r.get(o.index)??new Set,c=i.get(o.index);for(let t of e)c&&c.size>0&&!c.has(t)||s.add(t);r.set(o.index,s)}}function qn(e){let t=On(e.label,e.value);if(!t)return null;let n=new Set;return t.above&&n.add(`above`),t.below&&n.add(`below`),n.size>0?n:null}function Jn(e){return e}function Yn(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return i<=n||a<=r?0:(i-n)*(a-r)}export{Ye as $,Yt as A,le as At,_t as B,nn as C,re as Ct,qt as D,fe as Dt,an as E,ie as Et,Bt as F,yt as G,vt as H,V as I,_ as J,ot as K,Tt as L,Kt as M,ce as Mt,Et as N,te as Nt,Jt as O,pe as Ot,wt as P,de as Pt,Ke as Q,mt as R,$t as S,f as St,rn as T,d as Tt,xt as U,P as V,St as W,qe as X,Ge as Y,Je as Z,Sn as _,Se as _t,jn as a,We as at,Y as b,ve as bt,Dn as c,He as ct,wn as d,Re as dt,Qe as et,Tn as f,Le as ft,bn as g,xe as gt,xn as h,Te as ht,Pn as i,rt as it,Gt as j,ue as jt,Xt as k,ee as kt,$ as l,Ve as lt,vn as m,we as mt,Jn as n,Ze as nt,Nn as o,Be as ot,yn as p,Ie as pt,w as q,An as r,nt as rt,On as s,Ue as st,Yn as t,tt,En as u,ze as ut,Cn as v,Ce as vt,tn as w,ne as wt,Qt as x,_e as xt,sn as y,m as yt,ht as z};
|