agent-device 0.21.23 → 0.21.24
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 +6 -6
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.23.apk → agent-device-android-ime-helper-0.21.24.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.24.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.23.manifest.json → agent-device-android-ime-helper-0.21.24.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.23.apk → agent-device-android-snapshot-helper-0.21.24.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.24.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.23.manifest.json → agent-device-android-snapshot-helper-0.21.24.manifest.json} +6 -6
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/SnapshotTraversal.swift +12 -6
- package/apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/RectResponseTests.swift +21 -0
- package/apple/snapshot-bridge/README.md +9 -7
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandDispatch.swift +56 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +14 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +8 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +12 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCaptureTarget.swift +1 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotExecution.swift +29 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +34 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +19 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +3 -3
- package/dist/src/adapter.js +1 -1
- package/dist/src/adb.js +1 -1
- package/dist/src/agent-browser-lifecycle.js +1 -1
- package/dist/src/agent-browser-process-record.js +1 -1
- package/dist/src/agent-browser-provider.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/alert.js +1 -1
- package/dist/src/android-adb.d.ts +3 -2
- package/dist/src/android-input-ownership.js +1 -1
- package/dist/src/app-backend.js +1 -1
- package/dist/src/app-inventory.d.ts +4 -0
- package/dist/src/app-launch.js +1 -1
- package/dist/src/app-lifecycle.js +1 -1
- package/dist/src/app-log-runtime2.js +3 -3
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/app-state-runtime.d.ts +15 -0
- package/dist/src/apple-runner-platform.js +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/aws-device-farm-connection.js +1 -0
- package/dist/src/back-mode.js +1 -1
- package/dist/src/backend-snapshot-options.js +1 -1
- package/dist/src/browserstack-connection.js +1 -0
- package/dist/src/browserstack-device-features.js +1 -0
- package/dist/src/browserstack.js +1 -0
- package/dist/src/cache.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +35 -19
- package/dist/src/cli-runner.js +1 -1
- package/dist/src/cli.js +3 -4
- package/dist/src/client-companion-tunnel.js +1 -0
- package/dist/src/client-metro-companion.js +1 -1
- package/dist/src/client-metro.js +1 -1
- package/dist/src/client-types.d.ts +7 -5
- package/dist/src/cloud-artifacts.d.ts +3 -2
- package/dist/src/command-metadata.js +1 -1
- package/dist/src/command-schema.js +1 -1
- package/dist/src/command-tools.js +2 -2
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection-verification.js +1 -0
- package/dist/src/connection.js +5 -5
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/daemon-client-lease-beat.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -1
- package/dist/src/daemon-client-transport.js +1 -1
- package/dist/src/daemon-http.js +1 -1
- package/dist/src/daemon-policy-file.js +1 -1
- package/dist/src/daemon-registration-owner.js +1 -1
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-input-state.d.ts +2 -15
- package/dist/src/device-readiness-runtime.js +1 -1
- package/dist/src/device-selection-resolver.js +1 -1
- package/dist/src/device.js +1 -1
- package/dist/src/device2.js +1 -1
- package/dist/src/device3.js +1 -1
- package/dist/src/dispatch-resolve.js +3 -3
- package/dist/src/doctor-facade.js +1 -1
- package/dist/src/durable-capture-resource.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/exec.js +1 -1
- package/dist/src/file.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/format.js +2 -1
- package/dist/src/gesture-admission.js +1 -1
- package/dist/src/gesture-plan-types.d.ts +2 -5
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/human-control.js +1 -1
- package/dist/src/ime-rebind.js +1 -1
- package/dist/src/ime-settings-record.js +1 -0
- package/dist/src/ime-state.js +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/input-actions.js +1 -1
- package/dist/src/input-actions2.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/interaction-positionals.js +1 -1
- package/dist/src/interaction-ref-policy.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor.js +5 -5
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +1 -1
- package/dist/src/inventory2.js +1 -1
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-engine.js +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/launch-confirmation.js +1 -1
- package/dist/src/lease-scope.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun.d.ts +4 -555
- package/dist/src/load.js +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/managed-device-scope.js +1 -1
- package/dist/src/manifest.js +1 -0
- package/dist/src/mechanics.js +16 -16
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/observation.js +1 -2
- package/dist/src/overlay.js +3 -3
- package/dist/src/owner-identity.js +3 -3
- package/dist/src/perf-facade.js +1 -1
- package/dist/src/perf-runtime-plan.js +1 -1
- package/dist/src/perf-target.js +1 -1
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/platform-request-scope.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +4 -4
- package/dist/src/platform-runtime-runtime-hints.js +1 -1
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
- package/dist/src/platform-runtime-unavailable.js +1 -1
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/plugin.js +1 -0
- package/dist/src/plugins/webdriver.d.ts +111 -0
- package/dist/src/plugins/webdriver.js +1 -0
- package/dist/src/plugins.d.ts +2 -1
- package/dist/src/plugins2.js +1 -1
- package/dist/src/process-exit.js +1 -1
- package/dist/src/process.js +1 -1
- package/dist/src/provider-credential-fingerprint.js +1 -1
- package/dist/src/provider-device-admission.js +1 -1
- package/dist/src/provider-device-runtime.d.ts +556 -0
- package/dist/src/provider-policy.js +1 -0
- package/dist/src/provider-profile-fields.js +1 -1
- package/dist/src/provider-webdriver.js +1 -2
- package/dist/src/providers.js +1 -1
- package/dist/src/react-devtools.js +2 -0
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/record-trace.js +1 -1
- package/dist/src/recording.js +1 -1
- package/dist/src/registry.js +24 -24
- package/dist/src/remote-bridge.js +1 -0
- package/dist/src/remote-config-core.js +1 -0
- package/dist/src/remote-config.js +1 -1
- package/dist/src/remote-config2.js +1 -1
- package/dist/src/remote-connection-state.js +1 -0
- package/dist/src/replay.js +2 -2
- package/dist/src/request-admission.js +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/result-serialization.js +1 -1
- package/dist/src/retry.js +1 -1
- package/dist/src/retry2.js +1 -0
- package/dist/src/runner-artifact-manifest.js +1 -1
- package/dist/src/runner-cache-metadata.js +2 -3
- package/dist/src/runner-cache-retention.js +1 -0
- package/dist/src/runner-cache-trim.js +1 -0
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-dev-tools-security.js +1 -1
- package/dist/src/runner-device-readiness.js +1 -1
- package/dist/src/runner-device-set.js +1 -0
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-error-classification.js +1 -1
- package/dist/src/runner-exchange.js +1 -1
- package/dist/src/runner-lease.js +1 -0
- package/dist/src/runner-operations-facade.js +1 -1
- package/dist/src/runner-session-types.js +1 -1
- package/dist/src/runner-start-budget.js +1 -1
- package/dist/src/runner-toolchain-probe.js +2 -0
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime-deployment.js +1 -0
- package/dist/src/runtime.js +1 -1
- package/dist/src/runtime10.js +1 -2
- package/dist/src/runtime11.js +2 -0
- package/dist/src/runtime2.js +2 -5
- package/dist/src/runtime3.js +5 -1
- package/dist/src/runtime4.js +1 -5
- package/dist/src/runtime5.js +5 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-transport.js +1 -1
- package/dist/src/screenshot-density.js +1 -1
- package/dist/src/screenshot3.js +2 -2
- package/dist/src/script.js +1 -1
- package/dist/src/scroll-gesture.js +1 -1
- package/dist/src/sdk-batch.js +2 -2
- package/dist/src/sdk-contracts.d.ts +20 -29
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.d.ts +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-remote-config.d.ts +4 -0
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +1 -1
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-pipeline-policy.js +1 -1
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +2 -2
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session2.js +5 -5
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-boot.js +1 -1
- package/dist/src/simulator-state.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-capture-annotations.js +1 -1
- package/dist/src/snapshot-desktop-projection.js +1 -1
- package/dist/src/snapshot-private-evidence.js +1 -0
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot4.js +1 -1
- package/dist/src/src2.js +1 -1
- package/dist/src/src3.js +1 -1
- package/dist/src/src4.js +1 -1
- package/dist/src/src5.js +1 -1
- package/dist/src/src6.js +1 -1
- package/dist/src/src7.js +1 -1
- package/dist/src/src8.js +20 -20
- package/dist/src/store.js +1 -1
- package/dist/src/target-evidence.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/touch-runtime2.js +1 -1
- package/dist/src/tree.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/video.js +1 -1
- package/package.json +15 -10
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.23.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.23.apk.sha256 +0 -1
- package/dist/src/capabilities.js +0 -1
- package/dist/src/compatibility-policy.js +0 -1
- package/dist/src/daemon-artifacts.js +0 -1
- package/dist/src/device-claim-rule.js +0 -1
- package/dist/src/human-control-contract.js +0 -1
- package/dist/src/prepare-kind.js +0 -1
- package/dist/src/provider-device-runtimes.js +0 -1
- package/dist/src/screen-recording-admission-ledger.js +0 -1
- package/dist/src/screenshot-runtime.js +0 -1
- package/dist/src/session-routing.js +0 -1
- package/dist/src/session-runtime-admission.js +0 -1
- package/dist/src/timeouts.js +0 -1
- package/dist/src/touch-reference-frame.js +0 -1
- package/dist/src/vars.js +0 -2
- package/dist/src/viewport.js +0 -1
package/dist/src/runtime4.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import{F as e,I as t,J as n,K as r,P as i}from"./sdk-contracts.js";import{a,i as o,v as s}from"./sdk-batch-runner.js";import{c,r as l}from"./diagnostics.js";import"./diagnostics2.js";import{O as u,c as d,d as f,f as p,j as m,m as h,p as g,y as ee}from"./sdk-device.js";import{Xt as te,nn as _,rn as ne,tn as re}from"./sdk-batch.js";import{n as ie,r as ae}from"./session.js";import"./device.js";import{a as oe,u as v}from"./device-rotation.js";import{o as se,r as y}from"./exec.js";import"./command.js";import{r as ce}from"./version.js";import{n as le}from"./scoped-provider.js";import{i as ue,n as de,r as fe}from"./ios-snapshot-planning.js";import{t as pe}from"./request.js";import{n as me,r as he,t as ge}from"./application-lifecycle-runtime.js";import{A as _e,B as ve,C as ye,D as be,E as xe,G as Se,H as Ce,I as we,J as Te,K as Ee,L as De,N as Oe,O as ke,P as Ae,V as je,W as Me,d as Ne,h as Pe,j as Fe,n as Ie,o as Le,s as Re,v as ze,w as Be,x as Ve,z as He}from"./alert-runtime.js";import{n as Ue}from"./audio-probe-runtime.js";import{n as We}from"./perf-runtime.js";import{i as Ge,t as Ke}from"./touch-runtime.js";import{a as qe,n as Je}from"./durable-resource.js";import{n as Ye,t as Xe}from"./async-lifecycle.js";import{a as Ze,c as Qe,d as $e,f as et,l as tt,n as nt,o as rt,s as it,t as at,u as ot}from"./src7.js";import{n as st,t as ct}from"./screen-recording-completion.js";import{a as lt,c as ut,i as dt,n as ft,o as pt,r as mt,s as ht,t as gt}from"./device-readiness-runtime.js";import{n as _t}from"./screen-recording-runtime.js";import{t as vt}from"./ios-system-surface.js";import{i as yt,r as bt}from"./gesture-admission.js";import{t as xt}from"./interactor-operation-catalog.js";import{a as St,i as Ct,n as wt,r as Tt,t as Et}from"./perf-runtime-operation-builder.js";import{t as Dt}from"./app-log-runtime.js";import{n as Ot}from"./artifact-paths.js";import{i as kt,r as At}from"./managed-device-scope.js";import{a as jt,n as Mt,o as Nt}from"./application-lifecycle-interaction.js";import{f as Pt}from"./host-file.js";import{a as Ft,o as It,s as Lt}from"./config.js";import{a as Rt,o as zt}from"./tool-provider.js";import{o as Bt}from"./devicectl.js";import{t as Vt}from"./physical-device-apps.js";import{t as Ht}from"./apple-runner-platform.js";import{a as b,i as Ut,l as Wt,n as Gt,o as x,s as Kt}from"./simctl.js";import{a as qt,r as Jt}from"./simulator.js";import{r as Yt}from"./display-inventory.js";import{n as Xt,t as Zt}from"./app-backend.js";import{t as Qt}from"./simulator-state.js";import{a as $t,c as en,d as tn,i as nn,l as rn,n as an,o as on,r as sn,t as cn,u as ln}from"./cache.js";import{randomUUID as un}from"node:crypto";import S from"node:path";function dn(e){let t=kt();return Object.freeze(t?{...le({...e},e=>qt(t,e))}:e)}function fn(e,t){return Object.freeze({appState:async n=>{if(t.signal.throwIfAborted(),!await e.appleApplications.hasLiveRunnerSession(t.device,{}))return{};let r=await t.resolveInteractor(t.device,{appBundleId:n?.appBundleId,signal:t.signal});if(typeof r.appState!=`function`)throw ne(`Runtime owner advertised appState without an interactor implementation`);return await r.appState()}})}function pn(e){return pt(e)?Object.freeze({available:!0}):h(e)||g(e)&&e.kind===`simulator`?Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`audio probe capture requires a macOS host.`}):Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`audio is supported for macOS sessions and iOS simulators on macOS hosts; physical iOS devices expose no host audio tap.`})}function mn(e){let{resolveHost:t,device:n,owner:r}=e;return Object.freeze({...Et({platform:`Apple`,expectedProfileKind:`xctrace`,start:async e=>await t().start(n,r,e),reattach:async e=>await t().reattach(n,e),cleanup:async e=>await t().cleanup(n,e),writeProfileReport:async e=>await t().writeProfileReport(e)}),perfFrames:async({appId:e})=>({metric:e?await Ct(t().sampleFrames(n,e)):wt(`Apple`,`bundle ID`),sampling:await t().frameSampling(n)}),perfMemorySample:async({appId:e})=>({metric:e?await Ct(t().sampleMemory(n,e)):wt(`Apple`,`bundle ID`),sampling:await t().memorySampling(n)}),perfMemorySnapshot:async({appId:e,kind:r,outPath:i,artifactsDir:a})=>{let o=r??`memgraph`,s={...await t().memorySnapshotSupport(n),androidHprof:!1,heapprofd:!1};if(o!==`memgraph`)return St(`Apple`,o,s,`Use perf memory snapshot --kind memgraph for supported Apple app sessions.`);if(!e)throw Tt();let c=i??S.join(a,`memory-memgraph-${hn()}.memgraph`);return{artifact:await t().captureMemorySnapshot(n,e,c),support:s,sampling:{method:`xcrun memgraph`,description:`Native Apple memory graph captured for offline inspection.`,defaultKind:`memgraph`,artifactOnly:!0}}}})}function hn(){return new Date().toISOString().replaceAll(/[:.]/g,`-`)}const C=Object.freeze({available:!0}),w=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),T=yn(`Gestures are supported only for Apple simulators and devices.`),gn=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:bt}),_n=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:yt}),vn=yn(`scroll is supported only for Apple simulators and devices.`);function yn(e){return Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:e})}function bn(e){return{...we({unsupported:xn(e),plan:Sn(e),directionalFling:Sn(e),multiTouch:Cn(e),targetAuthoredDrag:wn(e),viewport:Tn(e)}),...Oe({scroll:En(e)})}}function xn(e){return e.appleOs===`watchos`||e.appleOs===`visionos`?w:T}function Sn(e){return e.appleOs===`watchos`||e.appleOs===`visionos`?w:E(e)?C:T}function Cn(e){if(e.appleOs===`watchos`)return w;if(!E(e))return T;let t=u(e);if(t!==`ios`&&t!==`ipados`){let e=Xt[t];return Object.freeze({available:!1,reason:`unsupported-platform-leaf`,...e===void 0?{}:{hint:e}})}return e.kind===`simulator`?C:gn}function wn(e){return E(e)?(e.appleOs===void 0?e.target!==`desktop`&&e.target!==`tv`:e.appleOs===`ios`||e.appleOs===`ipados`)?C:_n:T}function Tn(e){return e.appleOs===`watchos`?w:E(e)?C:T}function En(e){return E(e)?C:vn}function E(e){return e.kind===`simulator`||e.kind===`device`}const D=`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`;function O(e){return h(e)?`macos`:e.kind===`device`?`ios-device`:`ios-simulator`}const Dn=Object.freeze({resourceKind:Dt,version:1,encode:e=>({...e}),decode:e=>!kn(e.transport)||!An(e.backend)||!Pn(e.outputPath)||!Mn(e.pidPath)||!jn(e.transport,e.backend)?On():{status:`decoded`,descriptor:Object.freeze({transport:e.transport,backend:e.backend,outputPath:e.outputPath,...e.pidPath===void 0?{}:{pidPath:e.pidPath}})}});function On(){return{status:`invalid`,message:`Invalid Apple app-log descriptor`}}function kn(e){return e===`apple-log-stream`||e===`coredevice-console`}function An(e){return e===`ios-simulator`||e===`ios-device`||e===`macos`}function jn(e,t){return e===`coredevice-console`?t===`ios-device`:t!==`ios-device`}function Mn(e){return e===void 0||Pn(e)}function Nn(e){if(!e.device.appleOs)throw TypeError(`Apple app-log persistence requires an explicit appleOs identity`);return Je({resourceKind:Dt,sessionId:e.sessionId,device:{id:e.device.id,family:`apple`,appleOs:e.device.appleOs,kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target},...e.device.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.device.iosPhysicalDeviceBackend}},owner:e.owner,fence:e.fence,lifecycle:`open`,descriptor:qe(Dn,e.descriptor)})}function Pn(e){return typeof e==`string`&&e.trim().length>0}const Fn={message:`iOS physical-device app console capture is not supported by the installed devicectl.`,hint:`This devicectl does not expose process launch --console. Markers can still be written to app.log, but app output is not being captured. Use an iOS simulator for agent-device app logs or inspect physical-device logs in Console.app/Xcode until this Xcode toolchain exposes scriptable console capture.`},In={message:`Could not verify iOS physical-device app console capture support.`,hint:`Retry logs clear --restart. If the probe keeps failing, run logs doctor and inspect the request diagnostics for the devicectl help command.`};async function Ln(e,t){try{let n=await e.appleTools.run({tool:`devicectl`,args:[`device`,`process`,`launch`,`--help`],allowFailure:!0,timeoutMs:5e3},t),r=n.stderr.trim()||void 0;if(n.exitCode!==0)return{supported:!1,reason:`probe-failed`,stderr:r};let i=`${n.stdout}\n${n.stderr}`;return/\bUSAGE:\s+devicectl device process launch\b/i.test(i)&&/--console\b/.test(i)&&/--terminate-existing\b/.test(i)?{supported:!0,...r?{stderr:r}:{}}:{supported:!1,reason:`unsupported`,...r?{stderr:r}:{}}}catch(e){if(t?.aborted)throw t.reason;return{supported:!1,reason:`probe-failed`,...e instanceof Error?{stderr:e.message}:{}}}}async function Rn(e,t,n,r){let i={},a=n?[]:[`No app bundle is tracked in this session. Run open <app> first for app-scoped logs.`];if(h(t))i.logAvailable=!!await e.commands.which(`log`);else if(t.kind===`simulator`)i.simctlAvailable=await ut(async()=>ht(await e.appleTools.run({tool:`simctl`,args:Kt(),allowFailure:!0},r)),r);else if(t.iosPhysicalDeviceBackend===`xctest`)i.devicectlAvailable=!1,i.devicectlConsoleCapture=!1,a.push(D);else{i.devicectlAvailable=await ut(async()=>ht(await e.appleTools.run({tool:`devicectl`,args:[`--version`],allowFailure:!0},r)),r);let t=await Ln(e,r);if(i.devicectlConsoleCapture=t.supported,!t.supported){let e=t.reason===`unsupported`?Fn:In;a.push(`${e.message} ${e.hint}`)}}return{backend:O(t),checks:i,notes:a}}function zn(e,t){let n=Hn(e),r=[`subsystem == "${n}"`,`subsystem CONTAINS "${n}"`,`processImagePath ENDSWITH[c] "/${n}"`,`senderImagePath ENDSWITH[c] "/${n}"`];if(t){let e=Hn(t);r.push(`process == "${e}"`,`processImagePath ENDSWITH[c] "/${e}"`,`senderImagePath ENDSWITH[c] "/${e}"`,`processImagePath CONTAINS[c] "/${e}.app/"`,`senderImagePath CONTAINS[c] "/${e}.app/"`)}return r.join(` OR `)}function Bn(e,t){return Gt(e,[`spawn`,e.id,`log`,`stream`,`--style`,`compact`,`--level`,`info`,`--predicate`,zn(t.appBundleId,t.executableName)])}function Vn(e,t){return[`devicectl`,`device`,`process`,`launch`,`--device`,e,`--console`,`--terminate-existing`,t]}function Hn(e){return e.replaceAll(`\\`,String.raw`\\`).replaceAll(`"`,String.raw`\"`)}async function Un(e,t,n,r,i){Wn(t),rt(e,n);let a=O(t),o=await Kn(e,t,n.appBundleId,i),s=new Xe,c=!1;try{let l=await e.outputs.openAppend(n.outputPath);s.defer(async()=>{c||await l[Symbol.asyncDispose]()}),i?.throwIfAborted();let u=await Gn(e,t,o,l,n.pidPath,i);s.defer(async()=>{c||await u[Symbol.asyncDispose]()});let d=Jn(e,u,l,a,n.outputPath),f={transport:a===`ios-device`?`coredevice-console`:`apple-log-stream`,backend:a,outputPath:n.outputPath,...n.pidPath===void 0?{}:{pidPath:n.pidPath}},p=et(d,Nn({sessionId:n.sessionId,device:t,owner:r,fence:n.fence,descriptor:f}));return c=!0,p}finally{await s[Symbol.asyncDispose]()}}function Wn(e){if(e.appleOs===`watchos`)throw new i(`UNSUPPORTED_PLATFORM`,`watchOS app logs are not supported`);if(g(e)&&e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`)throw new i(`UNSUPPORTED_OPERATION`,D,{hint:D})}async function Gn(e,t,n,r,a,o){if(g(t)&&t.kind===`device`){let t=await Ln(e,o);if(!t.supported){let e=t.reason===`unsupported`?Fn:In;throw new i(t.reason===`unsupported`?`UNSUPPORTED_OPERATION`:`COMMAND_FAILED`,e.message,{backend:`ios-device`,hint:e.hint,stderr:t.stderr})}}return o?.throwIfAborted(),await e.processes.start({command:{kind:`host`,request:n},output:r,...a?{markerPath:a}:{}})}async function Kn(e,t,n,r){return h(t)?{executable:`log`,args:[`stream`,`--style`,`compact`,`--predicate`,zn(n)],allowFailure:!0}:t.kind===`device`?{executable:`xcrun`,args:Vn(t.id,n),allowFailure:!0}:{executable:`xcrun`,args:Bn(t,{appBundleId:n,executableName:await qn(e,t,n,r)}),allowFailure:!0}}async function qn(e,t,n,r){let i=await e.appleTools.run({tool:`simctl`,args:x(t,[`get_app_container`,t.id,n,`app`]),allowFailure:!0,timeoutMs:4e3},r),a=i.exitCode===0?i.stdout.trim():``;if(!a)return;let o=await e.commands.run({executable:`plutil`,args:[`-extract`,`CFBundleExecutable`,`raw`,`-o`,`-`,S.join(a,`Info.plist`)],allowFailure:!0,timeoutMs:4e3},r);return o.exitCode===0&&o.stdout.trim()||void 0}function Jn(e,t,n,r,i){let a=e.clock.now(),o=`active`;t.wait.then(e=>{o=e.exitCode===0?`ended`:`failed`},()=>{o=`failed`});let s;return ot({inspect:()=>({backend:r,state:o,startedAt:a}),finish:async()=>s??=(async()=>(await Yn([async()=>await t.terminate(),async()=>await t.wait.then(()=>void 0),async()=>await t[Symbol.asyncDispose](),async()=>await n[Symbol.asyncDispose]()])).length>0?(o=`failed`,{status:`cleanup-pending`,reason:`transport-failed`,message:`Apple app-log cleanup did not settle every owned resource`}):(o=`ended`,{status:`completed`,result:{backend:r,outputPath:i,completedAt:e.clock.now()}}))()})}async function Yn(e){let t=[];for(let n of e)try{await n()}catch(e){t.push(e)}return t}const k=te(`apple`),A=Object.freeze({available:!0});function Xn(e){return Object.freeze({owner:k,ownsDevice:e=>e.platform===`apple`,inspectFacts:async e=>Qn(e),bind:async t=>{if(t.intent.kind===`exact-owner`&&!re(t.intent.owner,k))throw new i(`UNSUPPORTED_OPERATION`,`Apple app-log owner identity does not match`);return Zn(e,t.device,t.scope.signal)},shutdown:async()=>void 0})}function Zn(e,t,n){if(t.platform!==`apple`)throw new i(`UNSUPPORTED_PLATFORM`,`Apple app-log owner cannot bind ${t.platform}`);let r=$e({codec:Dn,reattach:async(n,r)=>n.backend!==O(t)||!Ze(e,r.sessionId,n)?{status:`unreattachable`,reason:`descriptor-invalid`,message:`Apple app-log descriptor does not match the bound device or owning session`}:await Qe(e,n.pidPath),cleanup:async(n,r)=>n.backend===O(t)&&Ze(e,r.sessionId,n)?await it(e,n.pidPath):{status:`cleanup-pending`,reason:`ownership-fence-lost`,message:`Apple app-log descriptor does not match the bound device or owning session`}}),a=Object.freeze({appLogInspect:async()=>({backend:O(t)}),appLogDoctor:async({appBundleId:r})=>await Rn(e,t,r,n),appLogStart:async r=>await Un(e,t,r,k,n),...r});return Object.freeze({device:t,owner:k,facts:Qn(t),operations:a,[Symbol.asyncDispose]:async()=>void 0})}function Qn(e){if(e.appleOs===`watchos`)return $n(e);let t=g(e)&&e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?{available:!1,reason:`unsupported-device-backend`,hint:D}:A;return Object.freeze({device:{family:`apple`,appleOs:e.appleOs,kind:e.kind,...e.target===void 0?{}:{target:e.target},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend},providerMode:`local`},operations:{appLogInspect:t,appLogDoctor:t,appLogStart:t,appLogReattach:A,appLogCleanup:A}})}function $n(e){let t=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS app logs are not supported.`});return Object.freeze({device:{family:`apple`,appleOs:`watchos`,kind:e.kind,...e.target===void 0?{}:{target:e.target},providerMode:`local`},operations:{appLogInspect:t,appLogDoctor:t,appLogStart:t,appLogReattach:t,appLogCleanup:t}})}async function er(e,t,n,r){let i=O(t),a=await e.appLogs.readRecent(n.sessionId,n.maxScanLines),o=nt(a.text,{...n,path:a.path,exists:a.exists,lineNumberOffset:a.skippedLines,backend:i}),s=[];if(nr(t,n,o.dump)){let i=await rr(e,t,n,a.path,r);i&&(o=tr(s,o,i,n.maxEntries))}return or(s,t,n),ar(s,o.dump),o.dump.entries.length===0&&s.push(sr(t)),Object.freeze({source:`app-log`,backend:i,dump:o.dump,notes:Object.freeze(s)})}function tr(e,t,n,r){let i=n.scan.dump.entries.length;return i===0&&(n.scan.dump.unnamedRequests??0)===0?(n.lineCount>0&&e.push(`Recovered ${n.lineCount} recent iOS simulator app log lines from simctl log show, but none looked like HTTP traffic. This app may not emit request URLs, status, or timing into Unified Logging for this repro window.`),t):(i>0&&e.push(`Recovered ${i} iOS simulator HTTP entr${i===1?`y`:`ies`} from simctl log show (${n.lineCount} app log lines scanned).`),at(n.scan,t,r))}function nr(e,t,n){return g(e)&&e.kind===`simulator`&&!!t.appBundleId&&n.entries.length===0}async function rr(e,t,n,r,i){let a=n.appLogSnapshot?.startedAt,o=x(t,[`spawn`,t.id,`log`,`show`,`--style`,`compact`,`--info`,`--predicate`,ir(n.appBundleId),...typeof a==`number`&&Number.isFinite(a)&&a>0?[`--start`,`@${Math.floor(a/1e3)}`]:[`--last`,`5m`]]),s=await e.appleTools.run({tool:`simctl`,args:o,allowFailure:!0,timeoutMs:4e3},i);if(s.exitCode!==0||!s.stdout.trim())return;let c=s.stdout.split(`
|
|
2
|
-
`).map(e=>e.trimEnd()).filter(e=>e.trim()&&!e.trim().startsWith(`Timestamp Ty Process[PID:TID]`));if(c.length!==0)return{scan:nt(`${c.join(`
|
|
3
|
-
`)}\n`,{...n,path:`${r} (simctl log show recovery)`,exists:!0,backend:`ios-simulator`}),lineCount:c.length}}function ir(e){let t=e.replaceAll(`\\`,String.raw`\\`).replaceAll(`"`,String.raw`\"`);return[`subsystem == "${t}"`,`subsystem CONTAINS "${t}"`,`processImagePath ENDSWITH[c] "/${t}"`,`senderImagePath ENDSWITH[c] "/${t}"`].join(` OR `)}function ar(e,t){let n=t.entries.filter(e=>e.pathUnavailable).length,r=t.unnamedRequests??0,i=n+r;if(i===0)return;let a=[`${i} request${i===1?``:`s`} reused a keep-alive connection, so CFNetwork logged no request URL.`];n>0&&a.push(`${n} listed against the origin the connection was opened for, without a path.`),r>0&&a.push(`${r} opened before this scan window and are missing from the entries entirely; scan more lines, or run logs clear --restart before the repro.`),a.push(`Absence of an endpoint in this dump does not prove it was not called.`),e.push(a.join(` `))}function or(e,t,n){n.appLogSnapshot?n.appLogSnapshot.state!==`active`&&e.length===0&&e.push(g(t)&&t.kind===`simulator`?`Session app log stream is inactive. The iOS simulator recovery path scanned recent simctl log history, but a fresh logs clear --restart window is still the most reliable repro loop.`:`Session app log stream is inactive. Run logs clear --restart, reproduce the request window again, then rerun network dump.`):e.push(`Capture uses the session app log file. For fresh traffic, run logs clear --restart before reproducing requests.`)}function sr(e){return g(e)&&e.kind===`simulator`?`No HTTP(s) entries were found in recent iOS simulator app logs. If the app only emits non-HTTP diagnostics, inspect logs path or add app-side URLSession/network logging for per-request timing and payload details.`:g(e)?`No HTTP(s) entries were found in recent iOS device app logs. iOS network dump only sees what the app emits into Unified Logging for this process.`:`No HTTP(s) entries were found in recent session app logs.`}async function cr(t){let{host:n,snapshot:r,targetLabel:i,recorderWarning:a,nativePathDisposition:o}=t,s=r.invalidatedReason?{recorder:`lost`,why:`owner-session-lost`}:t.stopObservation;if(r.invalidatedReason&&!r.showTouches)throw Error(`recording invalidated: ${r.invalidatedReason}`);let c;try{c=await n.screenRecording.finalize.complete({outputPath:r.outPath,showTouches:!r.invalidatedReason&&r.showTouches,gestureEvents:r.gestureEvents,exportQuality:r.exportQuality??`medium`,...r.fps===void 0?{}:{fps:r.fps},targetLabel:i})}catch(t){throw e(t,`COMMAND_FAILED`)}let l=[...c.warning?[c.warning]:[],...a?[a]:[]];return ct(r,{...c,...l.length>0?{warning:l.join(` `)}:{},...r.invalidatedReason?{overlayWarning:`overlay unavailable: ${r.invalidatedReason}`}:{}},{stopObservation:s,...o===void 0?{}:{nativePathDisposition:o}})}async function lr(e){let{host:t,snapshot:n,targetLabel:r,collectedPath:i,exportPath:a,nativePath:o}=e;if(n.invalidatedReason&&!n.showTouches)throw Error(`recording invalidated: ${n.invalidatedReason}`);let s=e.overlayUnavailable??n.invalidatedReason,c;try{await t.screenRecording.outputs.copy({from:i,to:a}),c=await ur(()=>t.screenRecording.finalize.complete({outputPath:a,showTouches:s===void 0&&n.showTouches,gestureEvents:n.gestureEvents,exportQuality:n.exportQuality??`medium`,...n.fps===void 0?{}:{fps:n.fps},targetLabel:r}))}catch(e){throw await t.screenRecording.outputs.remove(a),e}return{...c,...s===void 0?{}:{overlayWarning:`overlay unavailable: ${s}`},nativePathDisposition:await t.screenRecording.outputs.remove(o)===`removed`?`retired`:`retirable`}}async function ur(t){try{return await t()}catch(t){throw e(t,`COMMAND_FAILED`)}}const dr=[`outPath`,`startedAt`,`clientOutPath`,...dt],j=Object.freeze({resourceKind:_t,version:1,encode:e=>e.backend===`simctl`?{backend:e.backend,outputPath:e.outputPath,processes:e.processes.map(e=>({...e})),...e.recording===void 0?{}:{recording:{...e.recording}}}:{backend:e.backend,outputPath:e.outputPath,appBundleId:e.appBundleId,runnerSessionId:e.runnerSessionId,runnerAuthority:e.runnerAuthority,...e.remotePath===void 0?{}:{remotePath:e.remotePath}},decode:e=>Cr(e)});function fr(e){let{device:t,owner:n,input:r,descriptor:i}=e;return Je({resourceKind:_t,sessionId:r.sessionId,device:m(t),owner:n,fence:r.fence,lifecycle:`open`,descriptor:qe(j,i)})}function pr(e){let t={};for(let n of dr)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}async function mr(e,t,n,r){let i=j.decode(n);return i.status!==`decoded`||!Nr(t,i.descriptor)?{status:`cleanup-pending`,reason:`manual-recovery-required`}:i.descriptor.backend===`simctl`?await hr(e,i.descriptor.processes,r):await _r(e,t,i.descriptor)}async function hr(e,t,n){let r=await Promise.all(t.map(async t=>await e.screenRecording.apple.inspectProcess(t)));if(r.includes(`ownership-lost`))return{status:`cleanup-pending`,reason:`ownership-fence-lost`};if(r.every(e=>e===`missing`))return n!==void 0&&e.screenRecording.ownedProcesses.clear(gr(n)),{status:`already-missing`};let i=await Promise.all(t.flatMap((t,n)=>r[n]===`owned-alive`?[e.screenRecording.apple.terminateProcess(t)]:[]));return i.includes(`ownership-lost`)?{status:`cleanup-pending`,reason:`ownership-fence-lost`}:(n!==void 0&&e.screenRecording.ownedProcesses.clear(gr(n)),i.every(e=>e===`already-missing`)?{status:`already-missing`}:{status:`cleaned`})}function gr(e){return{kind:`session`,sessionId:e}}async function _r(e,t,n){try{let r=await e.screenRecording.apple.inspectRunner(t,n.runnerSessionId,n.runnerAuthority);return r===`missing`?{status:`already-missing`}:r===`ownership-lost`?{status:`cleanup-pending`,reason:`ownership-fence-lost`}:(await e.screenRecording.apple.runRunner(t,{kind:`stop`,appBundleId:n.appBundleId,runnerSessionId:n.runnerSessionId,runnerAuthority:n.runnerAuthority}),{status:`cleaned`})}catch(e){return{status:`cleanup-pending`,reason:`transport-failed`,message:e instanceof Error?e.message:`Apple recording cleanup failed`}}}async function vr(e){let{host:t,device:n,envelope:r}=e,i=j.decode(r.descriptor.body);return i.status===`decoded`?Nr(n,i.descriptor)?i.descriptor.backend===`simctl`?await yr(e,i.descriptor):await xr(t,n,i.descriptor):M(`descriptor-invalid`,`Apple screen-recording descriptor does not match the bound device.`):M(`descriptor-invalid`,i.message)}async function yr(e,t){let n=await Promise.all(t.processes.map(async t=>await e.host.screenRecording.apple.inspectProcess(t)));if(!n.every(e=>e===`missing`))return M(`transport-not-reattachable`,n.includes(`ownership-lost`)?`Apple recording ownership no longer matches the durable descriptor.`:`Apple screen recordings require exact cleanup after daemon restart.`);let{recording:r}=t,i=br(mt(e.envelope.metadata),t.outputPath);return r===void 0||i!==void 0&&!await Sr(e.host,i)?{status:`missing`}:{status:`restore-export`,recording:r,nativePath:t.outputPath,cleanup:async()=>await hr(e.host,t.processes,e.envelope.sessionId)}}function br(e,t){if(e.finalization===void 0)return e.collectedPath??t}async function xr(e,t,n){let r=await e.screenRecording.apple.inspectRunner(t,n.runnerSessionId,n.runnerAuthority);return r===`missing`?{status:`missing`}:M(`transport-not-reattachable`,r===`ownership-lost`?`Apple recording ownership no longer matches the durable descriptor.`:`Apple screen recordings require exact cleanup after daemon restart.`)}async function Sr(e,t){try{return await e.screenRecording.finalize.sniff({outputPath:t}),!0}catch{return!1}}function M(e,t){return{status:`unreattachable`,reason:e,message:t}}function Cr(e){return typeof e.outputPath!=`string`||e.outputPath.length===0?P():e.backend===`simctl`?wr(e,e.outputPath):e.backend===`runner`?Dr(e,e.outputPath):P()}function wr(e,t){let n=Pr(e.processes),r=Tr(e.recording);return!n||r===`invalid`?P():{status:`decoded`,descriptor:Object.freeze({backend:`simctl`,outputPath:t,processes:n,...r===void 0?{}:{recording:r}})}}function Tr(e){if(e!==void 0)return s(e)&&Er(e)?Object.freeze(e):`invalid`}function Er(e){return N(e.outPath)&&kr(e.startedAt)&&Or(e.clientOutPath)&<(e)}function Dr(e,t){return!N(e.appBundleId)||!N(e.runnerSessionId)||!Ar(e.runnerAuthority)||!jr(e.remotePath)?P():{status:`decoded`,descriptor:Object.freeze({backend:`runner`,outputPath:t,appBundleId:e.appBundleId,runnerSessionId:e.runnerSessionId,runnerAuthority:e.runnerAuthority,...e.remotePath===void 0?{}:{remotePath:e.remotePath}})}}function N(e){return typeof e==`string`&&e.length>0}function Or(e){return e===void 0||N(e)}function kr(e){return typeof e==`number`&&Number.isFinite(e)}function Ar(e){return e===`local-lease`||e===`scoped-provider`}function jr(e){return e===void 0||Mr(e)}function Mr(e){return typeof e==`string`&&/^tmp\/agent-device-recording-\d+\.mp4$/.test(e)}function Nr(e,t){return e.kind===`simulator`?t.backend===`simctl`:t.backend===`runner`?e.appleOs===`macos`?t.remotePath===void 0:g(e)?t.remotePath!==void 0&&Mr(t.remotePath):t.remotePath===void 0:!1}function Pr(e){if(!Array.isArray(e)||e.length===0)return;let t=e.filter(e=>typeof e==`object`&&!!e&&Number.isInteger(e.pid)&&(e.pid??0)>0&&typeof e.startTime==`string`&&e.startTime.length>0&&typeof e.command==`string`&&e.command.length>0);return t.length===e.length?Object.freeze([...t]):void 0}function P(){return{status:`invalid`,message:`Invalid Apple screen-recording descriptor`}}async function Fr(e,t,n){if(e.kind!==`simulator`||t.scope!==`app`)return;let r=t.activeSessionApp?.bundleId;if(!r)throw TypeError(`App-scoped recording requires an active app session; open the app under test before recording.`);if(await n(r))throw TypeError(`App-scoped recording requires a real application session; open the app under test before recording.`)}const Ir=`iOS recording`,Lr=`simctl recordVideo`;function Rr(e){return e.appleOs===`watchos`?$r(`unsupported-platform-leaf`,`watchOS recording is not supported.`):g(e)&&e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?$r(`unsupported-device-backend`,`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`):Object.freeze({available:!0})}function zr(e){let{host:t,device:n,owner:r,signal:i}=e;return Object.freeze({screenRecordingStart:async e=>await Br({host:t,device:n,owner:r,input:e,signal:i}),screenRecordingReattach:async e=>{let r=await vr({host:t,device:n,envelope:e.envelope});return r.status===`restore-export`?{status:`active`,handle:Hr({host:t,restored:r})}:r},screenRecordingCleanup:async e=>await mr(t,n,e.envelope.descriptor.body,e.envelope.sessionId)})}async function Br(e){return e.signal.throwIfAborted(),e.device.kind===`simulator`?await Vr(e):await Wr(e)}async function Vr(e){let{host:t,device:n,owner:r,input:i,signal:a}=e;await Fr(n,i,t.screenRecording.apple.isRunnerBundleId);let o=i.activeSessionApp?await t.screenRecording.apple.captureClockAnchor(n,i.activeSessionApp.bundleId,a):void 0,s=Ot(i.outputPath);await t.screenRecording.outputs.prepare(s);let c=await t.screenRecording.apple.startSimulator(n,s,a),l=c.markers;if(!l||l.length===0)throw await Yr(c).catch(()=>{}),Error(`simctl recordVideo did not expose durable process identity`);try{a.throwIfAborted(),t.screenRecording.ownedProcesses.replace({kind:`session`,sessionId:i.sessionId},l.map(e=>({...e,purpose:`simctl-screen-recording`})))}catch(e){try{t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId})}catch{}throw await Yr(c).catch(()=>{}),e}let u,d,f=async()=>{await c.terminate();let e=await c.wait;return d=e,u=Kr(e),t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId}),{observation:{recorder:`confirmed`},...u===void 0?{}:{warning:`${u} before record stop; the video covers only what the recorder wrote before it stopped.`}}},p=Qr(i,Lr,{},o);return Zr({device:n,owner:r,input:i,descriptor:{backend:`simctl`,outputPath:s,processes:l,recording:pr(p)},snapshot:p,finish:(e,n)=>ft({snapshot:e,progress:n,steps:{stop:f,collect:async e=>{try{await Ur(t,s,e)}catch(e){throw qr(e,u,d)}},finalize:async({collectedPath:n,exportPath:r})=>{try{return await lr({host:t,snapshot:e,targetLabel:Ir,collectedPath:n,exportPath:r,nativePath:s})}catch(e){throw qr(e,u,d)}},discard:async e=>{await t.screenRecording.outputs.remove(e)}}}),cleanup:async()=>{let e=await Xr(c);return(e.status===`cleaned`||e.status===`already-missing`)&&t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId}),e}})}function Hr(e){let{host:t,restored:{recording:n,nativePath:r,cleanup:i}}=e,a=Object.freeze({...n,backend:Lr,gestureEvents:[]});return st(a,{finish:(e,i)=>ft({snapshot:e,progress:i,steps:{stop:async()=>({observation:{recorder:`confirmed`},warning:`simctl recordVideo had already ended when record stop reattached to it; the video covers only what the recorder wrote before it stopped.`}),collect:async e=>{await Ur(t,r,e)},finalize:async({collectedPath:i,exportPath:a})=>await lr({host:t,snapshot:e,targetLabel:Ir,collectedPath:i,exportPath:a,nativePath:r,...n.showTouches?{overlayUnavailable:`the daemon that held the touch events ended before record stop`}:{}}),discard:async e=>{await t.screenRecording.outputs.remove(e)}}}),forceCleanup:async()=>await i()})}async function Ur(e,t,n){await e.screenRecording.outputs.copy({from:t,to:n}),await e.screenRecording.finalize.sniff({outputPath:n})}async function Wr(e){let{host:t,device:n,owner:r,input:i,signal:a}=e,o=i.activeSessionApp?.bundleId;if(!o)throw TypeError(`Apple runner recording requires an active app session identity`);await t.screenRecording.outputs.prepare(i.outputPath);let s=await t.screenRecording.apple.runRunner(n,{kind:`start`,appBundleId:o,outputPath:i.outputPath,...i.fps===void 0?{}:{fps:i.fps}},a);if(!s.runnerSessionId||!s.runnerAuthority)throw Error(`Apple runner recording did not expose durable session ownership`);let c={runnerSessionId:s.runnerSessionId,runnerAuthority:s.runnerAuthority},l,u=()=>(l??=Gr(()=>t.screenRecording.apple.runRunner(n,{kind:`stop`,appBundleId:o,...c}).then(()=>void 0)).catch(e=>{throw l=void 0,e}),l);if(!Jr(n,s.remotePath))throw await u().catch(()=>{}),Error(`Apple runner recording did not expose coherent durable media ownership`);try{a.throwIfAborted()}catch(e){throw await u().catch(()=>{}),e}return Zr({device:n,owner:r,input:i,descriptor:{backend:`runner`,outputPath:i.outputPath,appBundleId:o,...c,...s.remotePath===void 0?{}:{remotePath:s.remotePath}},snapshot:Qr(i,`runner AVAssetWriter`,s),finish:async e=>(await u(),s.remotePath!==void 0&&await t.screenRecording.apple.retrieveRunnerRecording(n,s.remotePath,e.outPath),await cr({host:t,snapshot:e,targetLabel:n.appleOs===`macos`?`macOS recording`:`iOS recording`,stopObservation:{recorder:`confirmed`},...s.remotePath===void 0?{}:{nativePathDisposition:`retirable`}})),cleanup:async()=>(await u(),{status:`cleaned`})})}async function Gr(t){try{return await t()}catch(t){throw e(t,`COMMAND_FAILED`)}}function Kr(e){if(e.exitCode!==0)return e.signal?`simctl recordVideo was killed by ${e.signal}`:`simctl recordVideo exited with code ${e.exitCode}`}function qr(t,n,r){let a=e(t,`COMMAND_FAILED`);return n===void 0||r===void 0||a.details?.reason!==`recording-output-unplayable`?t:new i(a.code,`${a.message}; ${n}`,y(r,{...a.details??{},...r.signal===void 0?{}:{signal:r.signal},retriable:!1,hint:`The recorder exited before record stop, so the next record stop reads the same file. Close this session to release the device, then record again.`}))}function Jr(e,t){return e.appleOs===`macos`||!g(e)?t===void 0:t!==void 0&&/^tmp\/agent-device-recording-\d+\.mp4$/.test(t)}async function Yr(e){return await e.terminate(),await e.wait}async function Xr(e){try{return await Yr(e),{status:`cleaned`}}catch(e){return{status:`cleanup-pending`,reason:`transport-failed`,message:e instanceof Error?e.message:`Apple simulator cleanup failed`}}}function Zr(e){let{device:t,owner:n,input:r,descriptor:i,snapshot:a,finish:o,cleanup:s}=e,c=st(a,{finish:o,forceCleanup:s});return Object.freeze({pendingHandle:new Ye(c),envelope:fr({device:t,owner:n,input:r,descriptor:i})})}function Qr(e,t,n={},r){let i=Date.now();return Object.freeze({backend:t,outPath:e.outputPath,...e.clientOutputPath===void 0?{}:{clientOutPath:e.clientOutputPath},startedAt:i,scope:e.scope,showTouches:e.showTouches,recordOnlySession:e.recordOnlySession,...e.activeSessionApp===void 0?{}:{activeSessionApp:e.activeSessionApp},...e.exportQuality===void 0?{}:{exportQuality:e.exportQuality},...e.fps===void 0?{}:{fps:e.fps},gestureEvents:[],...r===void 0?{}:{gestureClockOriginAtMs:r.wallClockAtMs,gestureClockOriginUptimeMs:r.uptimeMs},...n.recorderStartUptimeMs===void 0?{}:{gestureClockOriginAtMs:i,gestureClockOriginUptimeMs:n.recorderStartUptimeMs,runnerStartedAtUptimeMs:n.recorderStartUptimeMs},...n.runnerSessionId===void 0?{}:{runnerSessionId:n.runnerSessionId}})}function $r(e,t){return Object.freeze({available:!1,reason:e,hint:t})}const ei=15e3;async function F(e,t,n,r={}){return n.throwIfAborted(),await At(t)||h(t)?{...t,booted:!0}:t.kind===`device`?(await e.deviceReadiness.applePhysical.ensureConnected(t,n),{...t,booted:!0}):t.kind===`simulator`?((await ti(e,t)?`Booted`:await si(e,t,n))!==`Booted`&&(r.onColdBootStart?.(),e.deviceReadiness.appleAutomation.keepHot(t),await ni(e,t,n,r.deadlineAtMs),await ci(e,n)),e.deviceReadiness.appleAutomation.keepHot(t),e.deviceReadiness.appleAutomation.markBooted(t),{...t,booted:!0}):{...t,booted:!0}}async function ti(e,t){try{return await e.deviceReadiness.appleAutomation.wasRecentlyObservedBooted(t)}catch{return!1}}async function ni(e,t,n,r=Date.now()+12e4){let i=!1;try{i=await ri(e,t,n,r),await ii(e,t,n,r)}catch(a){throw i&&n.aborted&&li(e,t),n.throwIfAborted(),Date.now()>=r?oi(t,a):a}}async function ri(e,t,n,r){let a=await e.appleTools.run({tool:`simctl`,args:x(t,[`boot`,t.id]),allowFailure:!0,timeoutMs:ai(r,t)},n),o=`${a.stdout}\n${a.stderr}`.toLowerCase(),s=o.includes(`already booted`)||o.includes(`current state: booted`);if(a.exitCode!==0&&!s)throw new i(`COMMAND_FAILED`,`simctl boot failed`,{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});return!s}async function ii(e,t,n,r){pe({type:`command`,status:`progress`,message:`Waiting for the Simulator to finish booting...`});let a=await e.appleTools.run({tool:`simctl`,args:x(t,[`bootstatus`,t.id,`-b`]),allowFailure:!0,timeoutMs:ai(r,t)},n);if(a.exitCode!==0)throw new i(`COMMAND_FAILED`,`simctl bootstatus failed`,{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});if(await Qt(e.appleTools,t,n,Math.min(ei,ai(r,t)))!==`Booted`)throw new i(`COMMAND_FAILED`,`Simulator is still booting`,{deviceId:t.id});if(Date.now()>=r)throw oi(t)}function ai(e,t){let n=e-Date.now();if(n<=0)throw oi(t);return n}function oi(e,t){return new i(`COMMAND_FAILED`,`Simulator did not finish booting within the startup budget`,{reason:gt,deviceId:e.id,hint:`The Simulator keeps booting in the background; a first boot can take several minutes. Retry once it is up, or pass a larger --timeout.`},t instanceof Error?t:void 0)}async function si(e,t,n){return await Qt(e.appleTools,t,n,ei)}async function ci(e,t){await e.commands.run({executable:`open`,args:[`-a`,`Simulator`],allowFailure:!0,timeoutMs:1e4},t)}function li(e,t){e.appleTools.run({tool:`simctl`,args:x(t,[`shutdown`,t.id]),allowFailure:!0}).catch(()=>{})}const ui=Object.freeze({resolveOpenTarget:`simulator`,prepareApplicationOpen:`simulator`,openApplication:`simulator`,applyRuntimeHints:`simulator`,clearRuntimeHints:`simulator`,closeApplication:`simulator`,finalizeApplicationClose:`simulator`,prepareAppleRunner:`runner`,configureProviderPortReverse:`simulator`,ensureReady:`simulator`,bootTarget:`simulator`,bootTargetHeadless:`simulator`,shutdownTarget:`simulator`,listApps:`simulator`,deployApp:`simulator`,materializeAppSource:`simulator`,deployMaterializedApp:`simulator`,sendPushNotification:`simulator`,appState:`simulator`,appLogStart:`simulator`,appLogInspect:`simulator`,appLogDoctor:`simulator`,appLogReattach:`simulator`,appLogCleanup:`simulator`,networkDump:`simulator`,audioProbeStart:`simulator`,audioProbeQuery:`simulator`,audioProbeReattach:`simulator`,audioProbeCleanup:`simulator`,readClipboard:`simulator`,writeClipboard:`runner`,setSetting:`simulator`,readSetting:`simulator`,setFoldPose:`simulator`,captureSnapshot:`simulator`,captureSnapshotWithoutActiveApp:`simulator`,captureSnapshotWithCustomActions:`runner`,captureScreenshot:`simulator`,findText:`runner`,readTextAtPoint:`runner`,tapPoint:`runner`,tapRef:`runner`,tapElementSelector:`runner`,fillPoint:`runner`,fillRef:`runner`,longPressPoint:`runner`,hoverPoint:`runner`,hoverRef:`runner`,focusPoint:`runner`,typeText:`runner`,scrollDirection:`runner`,performGesturePlan:`runner`,performMultiTouchGesturePlan:`runner`,performTargetAuthoredDrag:`runner`,performDirectionalFlingPlan:`runner`,gestureViewport:`runner`,setViewport:`runner`,back:`runner`,home:`runner`,setOrientation:`runner`,appSwitcher:`runner`,actionButton:`runner`,tvRemote:`runner`,keyboardDismiss:`runner`,keyboardEnter:`runner`,keyboardStatus:`runner`,triggerAppEvent:`runner`,readAlert:`runner`,awaitAlert:`runner`,acceptAlert:`runner`,dismissAlert:`runner`,perfFrames:`runner`,perfMemorySample:`runner`,perfMemorySnapshot:`runner`,perfNativeCaptureStart:`runner`,perfNativeCaptureReattach:`runner`,perfNativeCaptureCleanup:`runner`,perfProfileReport:`runner`,screenRecordingStart:`runner`,screenRecordingReattach:`runner`,screenRecordingCleanup:`runner`});function di(e){return e===void 0?`possible`:e.some(e=>ui[e]===`runner`)?`required`:`none`}const fi=3e3,pi=`simulator-target-discovery-pending`,mi=`simulator-target-unavailable`;function hi(){let e=new Map,t=new Map,n=ln({waitMs:1500});return async(r,i,a,o)=>{a.throwIfAborted();let s=`${r.id}:${i}`,c=e.get(s);if(c&&o!==`refresh`){let e=await rn(c.pid,{signal:a,timeoutMs:fi});if(a.throwIfAborted(),e===c.processStartTime)return c}return e.delete(s),await n.value(s,{start:async()=>{let n=await yi(r,i,t);return e.set(s,n),n},wait:(e,t)=>tn({waitMs:e,signal:a,stop:t,cancelled:()=>gi(a)}),pending:()=>I(pi,r,i)})}}function gi(e){return t({readinessPhase:`target-discovery`},e.reason)}function _i(e){return e instanceof i&&e.details?.reason===pi}function vi(e){return e instanceof i&&e.details?.reason===mi}async function yi(e,t,n){let r=Date.now()+15e3,[i,a]=await Promise.allSettled([b(e,[`spawn`,e.id,`launchctl`,`list`],{allowFailure:!0,timeoutMs:Si(r)}),bi(e,n,r)]);if(i.status===`rejected`)throw i.reason;if(a.status===`rejected`)throw a.reason;let o=i.value,s=a.value;if(o.exitCode!==0)throw I(`simulator-target-probe-failed`,e,t);let c=xi(o.stdout,t);if(!c)throw I(mi,e,t);let l=await rn(c.pid,{timeoutMs:Math.min(fi,Si(r))});if(!l)throw I(`simulator-target-identity-unavailable`,e,t);return Object.freeze({simulator:Wt(e),runtime:s,pid:c.pid,generation:`${c.pid}:${c.label}:${l}`,targetId:`${e.id}:${t}`,processStartTime:l})}async function bi(e,t,n){let r=t.get(e.id);if(r)return await r;let i=b(e,[`list`,`devices`,`-j`],{allowFailure:!0,timeoutMs:Si(n)}).then(t=>{if(t.exitCode!==0)throw I(`simulator-runtime-probe-failed`,e,``);let n=Object.entries(Ut(t.stdout)).find(([,t])=>t.some(t=>t.udid===e.id))?.[0];if(!n)throw I(`simulator-runtime-unavailable`,e,``);return n});t.set(e.id,i);try{return await i}catch(n){throw t.delete(e.id),n}}function xi(e,t){for(let n of e.split(`
|
|
4
|
-
`)){let[e,,r]=n.trim().split(/\s+/);if(!e||!r||!r.startsWith(`UIKitApplication:${t}[`))continue;let i=Number(e);if(Number.isSafeInteger(i)&&i>0)return{pid:i,label:r}}}function Si(e){return Math.max(1,e-Date.now())}function I(e,t,n){return new i(`COMMAND_FAILED`,`Unable to resolve the running iOS Simulator app (${e}).`,{reason:e,deviceId:t.id,appBundleId:n})}function Ci(e){return e?.observation===`unobservable`&&e.proof===`no-running-process`}const wi=new Map([[`application-element-missing`,5e3],[`application-server-unavailable`,5e3],[`foreground-owner-unverified`,1e3],[`foreground-owner-changed`,1e3]]);function L(e){return e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`}function Ti(e){let t=ue(fe({depth:1,interactiveOnly:!0}));return Object.freeze({awaitObservable:async(n,r,i)=>{if(!L(n))return{observation:`not-eligible`};let a;for(;;){let o=await Di(e.resolveTarget,n,r,i);if(`verdict`in o)return o.verdict;let{target:s}=o;if(e.isBridgeDisabled(s))return l({level:`debug`,phase:`ios_launch_observation_skipped`,data:{reason:`circuit-disabled`,deviceId:n.id,generation:s.generation}}),Ei({source:`circuit`});let c=await e.source.acquire({target:s,hint:t,signal:i});if(c.stage!==`failed`)return{observation:`observable`};i.throwIfAborted();let{kind:u,code:d}=c.failure,f=wi.get(d);if(f===void 0)return Ei({source:`bridge`,kind:u,code:d});let p=e.clock.now();if(a=Math.min(a??1/0,p+f),p>=a)return{observation:`unobservable`,proof:`launch-transition`};await e.clock.sleep(Math.min(150,a-p),i)}}})}function Ei(e){return{observation:`probe-failed`,failure:e}}async function Di(e,t,r,i){for(;;)try{return{target:await e(t,r,i)}}catch(e){if(i.throwIfAborted(),_i(e))continue;if(vi(e))return{verdict:{observation:`unobservable`,proof:`no-running-process`}};let{code:t,details:r}=n(e),a=r?.reason;return{verdict:Ei(typeof a==`string`?{source:`target`,code:t,reason:a}:{source:`target`,code:t})}}}function Oi(e,t,n){let r=n&&L(e),i=r?di(t.execution.plannedOperations):void 0,a=g(e)&&t.surface===`app`&&t.positionals.length>0&&!!t.appBundleId&&i!==`none`;return{...i?{runnerDemand:i}:{},shouldPrewarmRunner:a,awaitPrewarmAfterOpen:t.relaunch&&!r}}function ki(e,t,n,r){r.runnerDemand===`none`&&e.appleApplications.releaseSpeculativeRunner(t.device,n.execution).catch(()=>{})}async function Ai(e,t,n,r,a,o){let s=Date.now(),c=async()=>await Fi(t,n,r,a.observation),l=await c(),u,d=a.answerConfirmation,f=d&&l?.observation!==`observable`?await ji(d,a.redispatchLaunchUrl,c,l):void 0;if(f&&(o.runnerDemand=`required`,u=f.launchConfirmation,l=f.observed,f.unanswered))throw new i(`COMMAND_FAILED`,`The Simulator has not completed the launch URL for ${n.appBundleId}.`,{reason:`launch_confirmation_unanswered`,appBundleId:n.appBundleId,hint:`iOS may still be holding an "Open in" prompt, or the answer died with the runner session that raised it. Inspect the current alert before deciding on another action.`});return r&&l?.observation!==`observable`&&await e.clock.sleep(300,t.signal),l&&(o.postOpenObservation=l.observation,l.observation===`probe-failed`&&(o.postOpenObservationFailure=l.failure)),o.postOpenSettleDurationMs=Math.max(0,Date.now()-s),u}async function ji(e,t,n,r){let i={observed:r,acceptAttempted:!1,confirmationStillPresent:!1};for(let r=0;r<2;r+=1){i=await Mi(e,n,i);let a=r===1;if(i.confirmationStillPresent||a||!Ni(i)||!t)break;await t()}return{observed:i.observed,launchConfirmation:i.launchConfirmation,unanswered:Ni(i)||i.confirmationStillPresent}}async function Mi(e,t,n){let r=await e(),i=r.outcome===`unanswered`&&r.reason===`alert-still-present`,a=n.acceptAttempted||Pi(r),o=r.outcome===`accepted`?`accepted`:n.launchConfirmation;return a?{observed:await t(),launchConfirmation:o,acceptAttempted:a,confirmationStillPresent:i}:{observed:n.observed,launchConfirmation:o,acceptAttempted:a,confirmationStillPresent:i}}function Ni(e){return e.acceptAttempted&&Ci(e.observed)}function Pi(e){return e.outcome===`accepted`||e.outcome===`unanswered`&&e.reason===`alert-still-present`||e.outcome===`unreadable`&&e.step===`alert-accept`}async function Fi(e,t,n,r){if(!(!n||!L(e.device))&&!(!r||!t.appBundleId))return await r.awaitObservable(e.device,t.appBundleId,e.signal)}let Ii;const Li=()=>Ii??=import(`./launch-confirmation.js`);function Ri(e){let t=Mt({device:e.device,signal:e.signal,resolveInteractor:e.host.localInteractors.resolve});return Object.freeze({resolveOpenTarget:async t=>await e.host.appleApplications.resolveOpenTarget(e.device,t),prepareApplicationOpen:async t=>{await F(e.host,e.device,e.signal,{deadlineAtMs:t.execution.startupDeadlineAtMs,onColdBootStart:t.prewarmRunnerOnColdBoot?()=>{e.host.appleApplications.prewarmRunnerCache(e.device,t.execution,e.signal).catch(()=>{})}:void 0})},openApplication:async n=>await zi(e.host,t,n,e.observation),applyRuntimeHints:async t=>await e.host.appleApplications.applyRuntimeHints(e.device,t),clearRuntimeHints:async t=>await e.host.appleApplications.clearRuntimeHints(e.device,t),closeApplication:async n=>await Qi(e.host,t,n),finalizeApplicationClose:async t=>await $i(e.host,e.device,e.signal,t),prepareAppleRunner:async t=>await ea(e.host,e.device,e.signal,t),configureProviderPortReverse:oa})}async function zi(e,t,n,r){let i={},a=R(t.device),o=ra(t.device,n,a),s=ta(e,t,n,i),c=Oi(t.device,n,a);c.runnerDemand&&(i.runnerDemand=c.runnerDemand),ki(e,t,n,c);let{shouldPrewarmRunner:l}=c,u=Zi(t.device,n,a);a&&l&&!n.prewarmRunnerBeforeOpen&&s.schedule();try{await Bi(e,t,n,a,u,i),await Vi(n,i),await Hi(s,l,n.prewarmRunnerBeforeOpen);let d=s.wasAwaited();await Ui(t,n,o,a,i),await Ji(s,l,c.awaitPrewarmAfterOpen),await Yi(e,t,n,a,d,u);let f=await Ai(e,t,n,a,{observation:r,answerConfirmation:Ki(t,n,o),redispatchLaunchUrl:qi(t,n,o)},i);return{appBundleId:n.appBundleId,timing:i,...f?{launchConfirmation:f}:{}}}catch(n){throw u&&await e.appleApplications.stopRunnerSession(t.device.id).catch(()=>{}),n}}async function Bi(e,t,n,r,i,a){if(!Xi(n,r)||!n.target)return;let o=Date.now();f(t.device.platform)&&!r&&!i&&await e.appleApplications.stopRunnerSession(t.device.id),await jt({device:t.device,interactor:await t.resolveInteractor(n.execution,n.appBundleId),positionals:[n.appBundleId??n.target]}),r&&await e.clock.sleep(300,t.signal),a.relaunchCloseDurationMs=z(o)}async function Vi(e,t){if(!he(e.runtimeHints))return;if(!e.applyRuntimeHints)throw new i(`COMMAND_FAILED`,`Runtime hint operation was not admitted for this open.`,{reason:`runtime-hints-operation-missing`});let n=Date.now();await e.applyRuntimeHints({appId:e.appBundleId,values:e.runtimeHints}),t.runtimeHintsDurationMs=z(n)}async function Hi(e,t,n){!t||!n||(e.schedule(!0),await e.wait())}async function Ui(e,t,n,r,i){let a=Date.now();await Nt({device:e.device,interactor:await e.resolveInteractor(t.execution,t.appBundleId),positionals:n.positionals,appBundleId:t.appBundleId,execution:t.execution,...r&&t.relaunch&&!t.execution.clearAppState?{terminateRunningApp:!0}:{}}),i.openDispatchDurationMs=z(a),await Wi(e,t,n.followUpUrl,i)}async function Wi(e,t,n,r){if(!n){r.launchUrlDurationMs=0;return}let i=Date.now();await Gi(e,t,n),r.launchUrlDurationMs=z(i)}async function Gi(e,t,n){let r={...t.execution,clearAppState:void 0,launchConsole:void 0,launchArgs:void 0};await Nt({device:e.device,interactor:await e.resolveInteractor(r,t.appBundleId),positionals:[n],appBundleId:t.appBundleId,execution:r})}function Ki(e,t,{confirmation:n}){if(n)return async()=>{let{answerSimulatorLaunchConfirmation:r}=await Li();return await r(e.device,n,e.resolveInteractor(t.execution,n.appBundleId),e.signal)}}function qi(e,t,{confirmation:n}){if(n)return async()=>{await Gi(e,t,n.url)}}async function Ji(e,t,n){t&&!e.wasScheduled()&&e.schedule(),n?await e.wait():e.recordUnawaited()}async function Yi(e,t,n,r,i,a){!g(t.device)||!r&&!a||!n.relaunch&&!i||r&&!i&&!await e.appleApplications.hasLiveRunnerSession(t.device,n.execution)||await e.appleApplications.notifyRunnerAppRelaunched(t.device,n.execution,t.signal)}function Xi(e,t){return!!(e.relaunch&&e.target)&&!(t&&!e.execution.clearAppState)}function Zi(e,t,n){return e.kind===`device`&&e.appleOs===`ios`&&Xi(t,n)}async function Qi(e,t,n){n.ensureReady&&await F(e,t.device,t.signal),f(t.device.platform)&&!R(t.device)&&await e.appleApplications.stopRunnerSession(t.device.id),await jt({device:t.device,interactor:await t.resolveInteractor(n.execution,n.appBundleId),positionals:n.positionals}),R(t.device)&&await e.clock.sleep(300,t.signal)}async function $i(e,t,n,r){r.daemonShutdown||await e.appleApplications.releaseRunnerOnClose(t.id,{retain:r.retainRunner}),await e.appleApplications.dismissCloseAlerts(t,r).catch(()=>{});let i=r.shutdownTarget&&R(t)?await e.deviceShutdown.apple.shutdownTarget(t,n):void 0;return i===void 0?{}:{shutdown:i}}async function ea(e,t,n,r){let i=Date.now()+r.timeoutMs;await F(e,t,n,{deadlineAtMs:i});let a=Math.max(1,i-Date.now());return await e.appleApplications.prepareRunner(t,{...r,timeoutMs:a},n)}function ta(e,t,n,r){let i,a=!1,o=na(t.device,n)?{healthCheck:!1}:void 0;return{schedule:(a=!1)=>{i||=(r.runnerPrewarmKind=`session`,r.runnerPrewarmScheduled=!0,o?e.appleApplications.prewarmRunnerSession(t.device,n.execution,t.signal,a,o):e.appleApplications.prewarmRunnerSession(t.device,n.execution,t.signal,a))},wait:async()=>{if(!i||a)return;a=!0;let e=Date.now();await i,r.runnerPrewarmWaited=!0,r.runnerPrewarmDurationMs=z(e)},wasAwaited:()=>a,wasScheduled:()=>i!==void 0,recordUnawaited:()=>{i&&!a&&(r.runnerPrewarmWaited=!1)}}}function na(e,t){return e.kind===`device`&&e.appleOs===`ios`&&!t.hasExistingSession&&!t.relaunch&&!t.prewarmRunnerBeforeOpen}function ra(e,t,n){let r=t.runtimeLaunchUrl?.trim(),i=t.positionals.length===1?t.positionals[0]?.trim():void 0;if(!r||!i||o(i))return{positionals:t.positionals};let a=ia(e,t.appBundleId,r),s=a?{confirmation:a}:{};return n&&!aa(t)?{positionals:[i,r],...s}:{positionals:t.positionals,followUpUrl:r,...s}}function ia(e,t,n){if(e.appleOs===`ios`&&e.kind===`simulator`&&!(t===void 0||a(n)))return{url:n,appBundleId:t}}function aa(e){return e.execution.clearAppState===!0||!!e.execution.launchConsole?.trim()||!!e.execution.launchArgs?.length}function R(e){return g(e)&&e.kind===`simulator`}function z(e){return Math.max(0,Date.now()-e)}async function oa(){throw new i(`UNSUPPORTED_OPERATION`,`This lifecycle operation is unavailable for Apple.`)}const sa=Object.freeze({available:!0}),ca=Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`}),la=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`Push notifications are supported on Apple simulators only.`}),ua=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),da=Object.freeze({available:!1,reason:`unsupported-device-kind`});function fa(e){let t=ba(e);return Object.freeze({deployApp:t,materializeAppSource:t,deployMaterializedApp:t,sendPushNotification:xa(e)})}function pa(e){let{host:t,device:n,signal:r}=e,i=fa(n);return Object.freeze({...i.deployApp.available?{deployApp:async e=>await ma(t,n,e,r),materializeAppSource:async e=>await t.appleDeployment.prepareArtifact(e,{signal:r}),deployMaterializedApp:async e=>await ha(t,n,e,r)}:{},...i.sendPushNotification.available?{sendPushNotification:async e=>(await va(t,n,e,r),{})}:{}})}async function ma(e,t,n,r){if(n.replaceExisting)return await e.appleDeployment.withInvalidatedAppResolutionCache(t,async()=>{let i=await e.appleDeployment.resolveAppBundleId(t,n.app);await _a(e,t,i,r);let a=await e.appleDeployment.prepareArtifact({source:{kind:`path`,path:n.appPath}},{appIdentifierHint:n.app,signal:r});try{return await ga(e,t,a.installablePath,r),{bundleId:i,launchTarget:i}}finally{await a.cleanup()}});let i=await e.appleDeployment.prepareArtifact({source:{kind:`path`,path:n.appPath}},{appIdentifierHint:n.app,signal:r});try{return await ha(e,t,{artifact:i},r)}finally{await i.cleanup()}}async function ha(e,t,n,r){return await ga(e,t,n.artifact.installablePath,r),{...n.artifact.bundleId?{bundleId:n.artifact.bundleId}:{},...n.artifact.appName?{appName:n.artifact.appName}:{},...n.artifact.bundleId?{launchTarget:n.artifact.bundleId}:{}}}async function ga(e,t,n,r){await F(e,t,r),await ya(e,t.kind===`simulator`?{tool:`simctl`,args:x(t,[`install`,t.id,n])}:{tool:`devicectl`,args:[`device`,`install`,`app`,`--device`,t.id,n],timeoutMs:Ft},r,`Apple app install failed`)}async function _a(e,t,n,r){await F(e,t,r),await ya(e,t.kind===`simulator`?{tool:`simctl`,args:x(t,[`uninstall`,t.id,n])}:{tool:`devicectl`,args:[`device`,`uninstall`,`app`,`--device`,t.id,n]},r,`Apple app uninstall failed for ${n}`,{tolerate:e=>Vt(`${e.stdout}\n${e.stderr}`.toLowerCase())})}async function va(e,t,n,r){if(t.kind!==`simulator`)throw new i(`UNSUPPORTED_OPERATION`,`Apple push notifications require a simulator`);await F(e,t,r);let a=await e.temporaryFiles.create({prefix:`agent-device-ios-push-`,suffix:`.apns`});try{await a.writeText(`${JSON.stringify(n.payload)}\n`),await ya(e,{tool:`simctl`,args:x(t,[`push`,t.id,n.appId,a.path])},r,`Apple push notification failed`)}finally{await a[Symbol.asyncDispose]()}}async function ya(e,t,n,r,i){let a=await e.appleTools.run({...t,allowFailure:!0},n);return i?.tolerate?.(a)?a:se(a,r,e=>({cmd:`xcrun`,args:[t.tool,...t.args],...t.tool===`devicectl`?{hint:Bt(e.stdout,e.stderr)??`Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.`}:{}}))}function ba(e){return Sa(e)?e.kind!==`simulator`&&e.kind!==`device`?da:e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?ca:sa:ua}function xa(e){return Sa(e)?e.kind===`simulator`?sa:la:ua}function Sa(e){return g(e)&&e.appleOs!==`watchos`}const B=Object.freeze({available:!0}),Ca=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`back is supported on Apple simulators and physical devices.`}),wa=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function Ta(e){return e.kind!==`simulator`&&e.kind!==`device`?Ca:u(e)===`watchos`?wa:B}const Ea=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`home is supported on Apple simulators and physical devices.`}),Da=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),Oa=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`app-switcher is supported on Apple simulators and physical devices.`});function ka(e,t){if(e.kind!==`simulator`&&e.kind!==`device`)return t;let n=u(e);return n===`macos`||n===`watchos`?Da:B}function V(e){if(e.kind!==`simulator`&&e.kind!==`device`)return!1;let t=u(e);return t!==`tvos`&&t!==`macos`&&t!==`watchos`}const Aa=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`orientation is supported on Apple simulators and physical devices.`}),ja=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function Ma(e){return e.kind!==`simulator`&&e.kind!==`device`?Aa:V(e)?B:ja}const Na=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`tv-remote is supported only on tvOS devices.`});function Pa(e){return(e.kind===`simulator`||e.kind===`device`)&&ee(e)?B:Na}const H=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),Fa=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`keyboard status/get is currently supported only on Android; use keyboard dismiss or enter on iOS`});function Ia(e){return V(e)?Fa:H}function La(e){return V(e)?B:H}function Ra(e){return V(e)?B:H}const za=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`No Apple leaf carries this system button.`}),Ba=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`action-button is supported on iPhone and iPad simulators and physical devices.`}),Va=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`The Action Button is iPhone and iPad hardware; tvOS, macOS, watchOS and visionOS have no such control.`});function Ha(e){return e.kind!==`simulator`&&e.kind!==`device`?Ba:d(e)?B:Va}function Ua(e){return Object.freeze({...Be({back:Ta(e)}),...Ne({unsupported:za,home:ka(e,Ea),appSwitcher:ka(e,Oa),actionButton:Ha(e)}),...ye({orientation:Ma(e)}),...Ve({tvRemote:Pa(e)}),...ze({unsupported:H,status:Ia(e),dismiss:La(e),enter:Ra(e)})})}function Wa(e){let{host:t,device:n,signal:r,admitted:i}=e,a=Object.keys(Ua(n));return xt({device:n,signal:r,resolveInteractor:t.localInteractors.resolve,facts:Object.fromEntries(a.map(e=>[e,i[e]]))})}const U=Object.freeze({available:!0}),Ga=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`clipboard is supported on Apple simulators and the macOS host.`}),Ka=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`settings is supported on Apple simulators and the macOS host.`}),qa=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`settings is supported on Apple simulators and the macOS host, not on physical devices of this OS.`}),Ja=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:"Apple targets answer a settings read only on iPhone and iPad simulators, where `simctl ui` reports the value the device holds."}),Ya=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`clipboard is supported on Apple simulators and the macOS host, not on physical devices of this OS.`}),W=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function Xa(e,t,n){if(e.kind!==`simulator`&&e.kind!==`device`)return t;let r=u(e);return r===`watchos`?W:e.kind===`simulator`||r===`macos`?U:n}function Za(e){return Xa(e,Ga,Ya)}const Qa=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`trigger-app-event is supported on Apple simulators and physical devices.`}),$a=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`alert is supported on Apple simulators and physical devices.`}),eo=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`alert is supported on Apple simulators, the macOS host, and physical iOS devices.`});function to(e){if(e.kind!==`simulator`&&e.kind!==`device`)return $a;let t=u(e);return t===`watchos`?W:e.kind===`simulator`||t===`ios`||t===`macos`?U:eo}function no(e){return e.kind!==`simulator`&&e.kind!==`device`?Qa:u(e)===`watchos`?W:U}function ro(e){let t=Za(e);return t.available?Ya:t}function io(e){return e.kind!==`simulator`&&e.kind!==`device`?Ka:u(e)===`watchos`?W:p(e)?U:Ja}function ao(e){let t=Za(e),n=to(e);return Object.freeze({...Pe({unsupported:ro(e),read:t,write:t}),...Ie({read:n,wait:n,accept:n,dismiss:n}),...Re({triggerAppEvent:no(e)}),...Le({setSetting:Xa(e,Ka,qa),readSetting:io(e)})})}function oo(e){let{host:t,device:n,signal:r}=e;return xt({device:n,signal:r,resolveInteractor:t.localInteractors.resolve,facts:ao(n)})}function so(e){return Object.freeze({setFoldPose:e.fold})}const co=/Angle:\s*(-?\d+(?:[.,]\d+)?)\s*°/g;async function lo(e,t={}){let n=[`devicectl`,`device`,`motion`,`hinge-angle`,`--device`,e.id,`--session-timeout`,`1`,`--timeout`,`5`],r=await zt(n,{allowFailure:!0,signal:t.signal,timeoutMs:Lt}),a=uo(r.stdout)??uo(r.stderr);if(a!==void 0)return a;throw new i(`COMMAND_FAILED`,`CoreDevice reported no hinge angle sample`,y(r,{cmd:`xcrun`,args:n,stdout:r.stdout,stderr:r.stderr,deviceId:e.id,hint:`This Xcode/CoreDevice toolchain does not stream 'devicectl device motion hinge-angle' for this device. Foldable poses can be verified only through that stream; update Xcode to a version that ships it.`}))}function uo(e){let t;for(let n of e.matchAll(co)){let e=Number.parseFloat(n[1].replace(`,`,`.`));Number.isFinite(e)&&(t=e)}return t}const fo=`Fold.m`,po=3e4,mo=Ht+po;async function ho(e={}){let t=e.host??go(),n=on(mo,e.signal);try{let r=e.sourceRoot??S.join(ce(),`apple`,`fold-helper`),i=await sn(t,r,[fo],n),a=await nn(t,n),o=e.cacheRoot??S.join(Pt(),`.agent-device`,`fold-helper`);return await cn({host:t,deadline:n,lockDescription:`iOS Simulator fold helper cache`,cacheRoot:o,binaryFilename:`fold-helper`,keyInputs:{schemaVersion:1,sourceHash:i,toolchain:a,compileArgv:_o({sourceRoot:``,outputPath:``})},build:e=>vo(t,n,r,e)})}catch(e){throw yo(e)}}function go(){return $t(Rt)}function _o(e){return[`--sdk`,`iphonesimulator`,`clang`,`-mios-simulator-version-min=15.0`,`-fobjc-arc`,`-Wall`,`-Wextra`,`-framework`,`Foundation`,`-framework`,`IOKit`,S.join(e.sourceRoot,fo),`-o`,e.outputPath]}async function vo(e,t,n,r){let i=await an({host:e,deadline:t,argv:_o({sourceRoot:n,outputPath:r}),budgetMs:po,label:`fold helper`});if(i.exitCode!==0||!e.exists(r))throw bo(y(i))}function yo(e){return!(e instanceof en)||e.buildFailureKind===`cancelled`?e:bo({...e.buildDetails,cause:e.buildFailureCode},e)}function bo(e,t){return new i(`COMMAND_FAILED`,`Unable to build the simulator fold helper`,{hint:`Select an Xcode with the iOS simulator SDK and foldable HID support using DEVELOPER_DIR.`,...e,reason:`fold-helper-build-failed`},t)}async function xo(e,t,n){n?.throwIfAborted();let r=await ho({signal:n});n?.throwIfAborted();let a=typeof t==`string`?0:t.at(-1).atMs,o=typeof t==`string`?t:JSON.stringify(t),s=await b(e,[`spawn`,e.id,r.path,o],{signal:n,timeoutMs:a+1e4,kill:{signal:`SIGTERM`,graceMs:1e3},allowFailure:!0});if(s.exitCode!==0)throw new i(`COMMAND_FAILED`,`Unable to send the simulator hinge pose`,y(s,{reason:`fold-hid-dispatch-failed`,deviceId:e.id}))}async function So(e,t,n={}){n.signal?.throwIfAborted(),Jt(e,`fold`);let r=t,i=r.keyframes?.at(-1)?.angle,a=r.pose??v(i);Co(e,await Yt(e,{signal:n.signal})),await xo(e,r.keyframes??a,n.signal),l({level:`info`,phase:`apple_fold_pose_dispatched`,data:{deviceId:e.id,pose:a}});let o=await wo(e,a,n.signal,i),s=await No(e,n.signal);return{pose:v(o),hingeAngleDegrees:o,...s?{screen:Po(s)}:{}}}function Co(e,t){if(t.unresolved)throw new i(`COMMAND_FAILED`,`CoreDevice reported no display table for this simulator`,{deviceId:e.id,hint:`fold needs 'devicectl device info displays' to tell a foldable from a single-panel simulator; update Xcode to a version that ships the display-information feature.`});if(!t.multiScreen)throw new i(`UNSUPPORTED_OPERATION`,`${e.name} is not a foldable simulator: fold requires more than one integrated panel`,{deviceId:e.id,reason:`single-panel-device`,hint:`fold sets the hinge angle of a foldable simulator such as iPhone Duo; this simulator reports one integrated panel, so it has no hinge to pose.`})}async function wo(e,t,n,r){let i,a;for(let o=1;o<=4;o+=1)if(n?.throwIfAborted(),a=i,i=await lo(e,{signal:n}),To(i,a,t,r))return i;throw Oo(e,t,i,a,r)}function To(e,t,n,r){return r===void 0?v(e)===n?n!==`half-open`||t!==void 0&&ko(e,t):!1:Eo(e,t,r)}function Eo(e,t,n){return Do(e,n)?n===0||n===180||t!==void 0&&Do(t,n)&&Math.abs(e-t)<=.5:!1}function Do(e,t){return t===void 0||e!==void 0&&Math.abs(e-t)<=.5}function Oo(e,t,n,r,a){return Do(n,a)?a!==void 0&&n!==void 0?Mo(e,v(n),n,r):n!==void 0&&t===`half-open`&&v(n)===t?Mo(e,t,n,r):jo(e,t,n):new i(`COMMAND_FAILED`,`The hinge did not reach the final keyframe angle`,{reason:`fold-angle-unverified`,targetAngleDegrees:a,hingeAngleDegrees:n,deviceId:e.id})}function ko(e,t){return v(e)===`half-open`&&v(t)===`half-open`&&Math.abs(e-t)<=.5}function Ao(e,t,n){return{deviceId:e.id,requestedPose:t,observedPose:n===void 0?void 0:v(n),hingeAngleDegrees:n}}function jo(e,t,n){return new i(`COMMAND_FAILED`,`${e.name} did not reach the ${t} pose: CoreDevice still reports a hinge angle of ${n}°`,{...Ao(e,t,n),reason:`fold-pose-unverified`,hint:`The simulator HID command completed, but the hinge did not follow. Verify that the selected Xcode and simulator runtime support foldable HID control, then retry.`})}function Mo(e,t,n,r){return new i(`COMMAND_FAILED`,`${e.name} was observed ${t} at ${n}° but did not settle: 4 hinge reads never held two consecutive angles within ${It}° of each other`,{...Ao(e,t,n),reason:`fold-pose-unsettled`,...r===void 0?{}:{previousHingeAngleDegrees:r},hint:`The hinge reached the requested pose and was still moving when the read budget ended. Retry the fold, then read the angle directly with xcrun devicectl device motion hinge-angle --device <udid> --session-timeout 1 --timeout 5 to see whether the simulator holds the pose.`})}async function No(e,t){let n=await Yt(e,{signal:t});if(!(n.unresolved||n.ambiguous))return n.activeDisplay}function Po(e){return{display:e.name,coordinateSpace:oe,widthPt:Math.round(e.widthPx/e.pointScale),heightPt:Math.round(e.heightPx/e.pointScale)}}const Fo=Object.freeze({available:!0}),Io=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`fold is supported on foldable iPhone simulators controlled through simulator HID; a physical device is folded by hand.`}),Lo=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`fold poses the hinge of a foldable iPhone; tvOS, macOS, watchOS and visionOS simulators have no hinge.`});function Ro(e){return{available:!1,reason:`unsupported-device-scope`,hint:`fold cannot resolve a simulator scoped to the set at "${e}": CoreDevice's display inventory and hinge-angle readback need a simulator in the default set, so the pose could not be verified. Run fold without --ios-simulator-device-set.`}}function zo(e){if(e.kind!==`simulator`)return Io;let t=u(e);return t!==`ios`&&t!==`ipados`?Lo:e.simulatorSetPath?Ro(e.simulatorSetPath):Fo}function Bo(e){return so({fold:zo(e)})}function Vo(e){let{device:t,signal:n}=e;return _(Bo(t).setFoldPose,()=>({setFoldPose:async e=>(n.throwIfAborted(),await So(t,e,{signal:n}))}))}function Ho(e,t,n){let r=Ce({device:t.device,signal:t.signal,resolveInteractor:e.localInteractors.resolve}),i=async i=>{let a=h(t.device)?ie(i.options?.surface,t.appBackend):void 0;if(a)return await e.snapshot.captureSurface(t.device,{...i.options,surface:a},Me(t.signal,i));if(!n)return await r.captureSnapshot(i);let o=Me(t.signal,i);return await n.capture(t.device,i,o,async e=>await r.captureSnapshot(e))};return Object.freeze({captureSnapshot:i,captureSnapshotWithCustomActions:i,captureSnapshotWithoutActiveApp:i})}function Uo(e,t){return Object.freeze({findText:async n=>{let r=await Wo(e,t,n);if(!r)return{found:!1};let i=await e.localInteractors.resolve(t.device,{...n.execution,...r});return i.findText?await i.findText(n.text,r):{found:!1}}})}async function Wo(e,t,n){let r=n.options?.appBundleId;if(r===void 0||h(t.device)&&ae(n.options?.surface,t.appBackend)===`macos-helper`)return;let i=n.signal?AbortSignal.any([t.signal,n.signal]):t.signal;if(i.throwIfAborted(),await Go(e,t.device,n.execution))return{appBundleId:r,signal:i}}async function Go(e,t,n){return!L(t)||await e.appleApplications.hasLiveRunnerSession(t,n??{})}const G=Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`The native macOS app backend never starts the XCTest runner, which this command needs. Unset AGENT_DEVICE_MACOS_APP_BACKEND to use XCTest.`});function Ko(e,t){return!h(e)||t!==`native`?{}:Object.freeze({screenRecordingStart:G,screenRecordingReattach:G,prepareAppleRunner:G,longPressPoint:G,...Be({back:G}),...we({unsupported:G})})}function qo(){let e,t=!1,n=async()=>(e??=import(`./adapter.js`).then(({createSimulatorSnapshotSource:e})=>e()),await e);return{acquire:async e=>t?{stage:`failed`,failure:{kind:`unsupported`,code:`source-closed`}}:await(await n()).acquire(e),close:async()=>{t=!0,e&&await(await e).close()}}}function Jo(e=Date.now){let t=new Map;return async(n,r)=>{if(n.kind!==`simulator`)return`absent`;let i=t.get(n.id);if(i!==void 0&&e()-i.at<1e3)return{kind:`present`,host:i.host};t.delete(n.id);let a=await Yo(n,r);return a!==`absent`&&a!==`unknown`&&t.set(n.id,{at:e(),host:a.host}),a}}async function Yo(e,t){let n=!1;for(let r of vt){let i=await Xo(r.processExecutable,t);if(i===`unknown`){n=!0;continue}for(let a of i){let i=await Zo(a,e.id,t);if(i===`unknown`)n=!0;else if(i)return{kind:`present`,host:r}}}return n?`unknown`:`absent`}async function Xo(e,t){let n=await Qo(`pgrep`,[`-f`,e],t);return n===`unknown`?`unknown`:n.exitCode===1?[]:n.exitCode===0?n.stdout.split(`
|
|
5
|
-
`).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isSafeInteger(e)&&e>0):`unknown`}async function Zo(e,t,n){let r=await Qo(`ps`,[`eww`,`-p`,String(e),`-o`,`command=`],n);return r===`unknown`||r.exitCode!==0?`unknown`:r.stdout.includes(`SIMULATOR_UDID=${t}`)?!0:!r.stdout.includes(`SIMULATOR_UDID=`)&&`unknown`}async function Qo(e,t,n){try{let r=await Rt(e,t,{allowFailure:!0,timeoutMs:3e3,...n?{signal:n}:{}});return{exitCode:r.exitCode,stdout:r.stdout}}catch{return`unknown`}}const $o=`system-surface-presented`,es=`system-surface-host-lingering`,ts=`window-coordinate-space-unresolved`;function ns(e,t={}){let n=t.source??qo(),r=t.resolveTarget??hi(),a=t.systemSurfacePresent??Jo(),o=new Set,s=new Map,l=e=>(_s(e,s,o),o.has(vs(e))),u=Ti({source:n,resolveTarget:r,clock:e.clock,isBridgeDisabled:l});return Object.freeze({awaitObservable:u.awaitObservable,shutdown:async()=>await n.close(),capture:async(t,s,u,d)=>{if(!as(t,s))return await ls(t,s,d);let f=await a(t,u);if(f===`unknown`)return await K(t.id,s,d,ds(t.id,s),q(s),`system-surface-probe-unavailable`,[gs()]);if(f!==`absent`)return await cs(t,s,d,f.host.bundleId);let p;try{p=await rs(e,r,t,s,u)}catch(e){return is(u,e),J(`target-resolution-failed`,t,void 0,e),await K(t.id,s,d,ds(t.id,s),q(s),`target-resolution-failed`,[gs()])}if(l(p))return J(`circuit-disabled`,t,p.generation),await K(t.id,s,d,p,q(s),`circuit-disabled`);let m=q(s),h=await n.acquire({target:p,hint:ue(m),signal:u});if(h.stage===`failed`){if(h.failure.kind===`cancelled`)throw u.throwIfAborted(),new i(`COMMAND_FAILED`,`Simulator AX snapshot acquisition was cancelled.`,{reason:h.failure.code,...h.failure.details});let e=await hs(h.failure,p,t,s.options.appBundleId,u,r);return await os(s,d,p,e,m,h.failure,o)}try{return await c(`ios.snapshot-source.present`,async()=>await e.snapshot.presentIosAcquisition(h,s.options),{producer:`simulator-ax-bridge`})}catch(e){return await os(s,d,p,{lineage:p,residue:[]},m,{kind:`malformed-tree`,code:`presentation-invariant`},o,e)}}})}async function rs(e,t,n,r,i){let a=r.options.appBundleId;for(;;)try{return await t(n,a,i)}catch(t){if(!_i(t))throw t;let i={requestId:r.execution?.requestId};if(await e.appleApplications.hasLiveRunnerSession(n,i))throw t}}function is(e,t){if(e.aborted)throw r(t)?t:e.reason}function as(e,t){return e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`&&!!t.options?.appBundleId&&t.options?.customActions!==!0&&t.options?.preferredBackend===void 0}async function os(e,t,n,r,i,a,o,s){return ss(a)&&o.add(vs(n)),J(a.code,{id:n.simulator.udid},n.generation,s,a.details),await K(n.simulator.udid,e,t,r.lineage,i,a.code,r.residue)}function ss(e){return e.kind!==`preparing`&&e.code!==ts}async function K(e,t,n,r,i,a,o=[]){return us(e,await n(t),r,i,a,o)}async function cs(e,t,n,r){let i=await n(t),a=i.systemSurface?$o:es;return i.systemSurface||J(a,e,void 0,void 0,{detectedHost:r}),us(e.id,i,ds(e.id,t),q(t),a)}async function ls(e,t,n){let r=await n(t),i=r.systemSurface;return i?{...r,comparisonIdentity:ps(fs(e.id,i.bundleId),q(t),[])}:r}function us(e,t,n,r,i,a=[]){let o=t.systemSurface;return{...t,comparisonIdentity:ps(o?fs(e,o.bundleId):n,r,[...o?[]:a,{kind:`fallback-source`,producer:`apple-runner`}]),warnings:[...t.warnings??[],ms(i,n,o!==void 0)]}}function ds(e,t){return{targetId:`${e}:${t.options.appBundleId}`}}function fs(e,t){return{targetId:`${e}:${t}`}}function ps(e,t,n){return Object.freeze({producer:`apple-runner`,intent:t.acquisitionIntent,lineage:Object.freeze({...e.targetId?{targetId:e.targetId}:{},...e.generation?{generation:e.generation}:{}}),presentationKey:de(t),residue:Object.freeze([...n])})}function ms(e,t,n){return e===$o?`Simulator AX snapshot inapplicable (${e}); used XCTest to read the system surface presented over the app.`:e===es?`Simulator AX snapshot inapplicable (${e}); used XCTest, which read app content: the system surface host process was still running but no longer presenting.`:n?`Simulator AX snapshot unavailable (${e}); used XCTest, which read the system surface presented over the app.`:e===`bridge-preparation-pending`?`Simulator AX snapshot unavailable (${e}); used XCTest for this capture while the bridge is still being prepared.`:e===ts?`Simulator AX snapshot unavailable (${e}); used XCTest for this capture, which reports captured geometry in the app's own orientation space.`:`Simulator AX snapshot unavailable (${e}); used XCTest for ${t.generation?`this app generation`:`an unverified app generation`}.`}async function hs(e,t,n,r,i,a){if(e.kind!==`stale-target`)return{lineage:t,residue:[]};try{return{lineage:await a(n,r,i,`refresh`),residue:[]}}catch(e){return i.throwIfAborted(),J(`fallback-target-resolution-failed`,n,void 0,e),{lineage:{targetId:t.targetId},residue:[gs()]}}}function gs(){return{kind:`unknown-generation`,captureId:un()}}function q(e){return fe({raw:e.options?.raw,interactiveOnly:e.options?.interactiveOnly,depth:e.options?.depth,scope:e.options?.scope,customActions:e.options?.customActions,acquisitionIntent:e.options?.acquisitionIntent})}function _s(e,t,n){let r=t.get(e.targetId);r&&r!==e.generation&&n.delete(`${e.targetId}:${r}`),t.set(e.targetId,e.generation)}function vs(e){return`${e.targetId}:${e.generation}`}function J(e,t,n,r,i){l({level:`debug`,phase:`ios_snapshot_route_fallback`,data:{reason:e,deviceId:t.id,...n?{generation:n}:{},...r?{error:r instanceof Error?r.message:String(r)}:{},...i?{details:i}:{}}})}const Y=te(`apple`),X=Object.freeze({available:!0}),Z=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),ys=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`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.`}),bs=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`the stateless audio page probe is a web-session operation; Apple targets use the host capture.`}),xs=Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`perf requires an Apple simulator, macOS device, or CoreDevice-backed physical Apple device.`}),Ss=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`focus is supported on Apple simulators and physical devices.`}),Cs=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Apple appstate is unavailable here: the runner reads the session app's XCUIApplication state on iOS-family simulators and physical devices only, and the Apple target answers no sessionless foreground probe. The per-command answer is the targetActivation disclosure, which a capture carries when its command had to re-activate the session app (#2682).`});function ws(e){return!g(e)||e.appleOs===`watchos`?Cs:e.kind===`simulator`||e.kind===`device`?X:Cs}const Ts=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is supported only for local Android emulators.`}),Es=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS has no XCUITest-driveable UI, so element text comes from the captured tree only.`}),Ds=Object.freeze({available:!1,reason:`unsupported-device-kind`}),Os=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS open is not supported because XCUITest cannot drive watchOS UI.`}),ks=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS runner preparation is not supported because XCUITest cannot drive watchOS UI.`}),As=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS close is not supported because XCUITest cannot drive watchOS UI.`}),js=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`Runtime hints are supported only for local iOS-family simulators and Android devices.`}),Ms=Q(`open is supported only for Apple simulators and devices.`),Ns=Q(`prepare is supported only for Apple simulators and devices.`),Ps=Q(`close is supported only for Apple simulators and devices.`),Fs=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Port reverse is supported only by an owning provider runtime.`}),Is=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`shutdown is supported only for Apple simulators and Android emulators.`}),Ls=Q(`snapshot is supported only for Apple simulators and devices.`),Rs=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Re-run without --actions, or target an iOS simulator.`}),zs=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`screenshot is not supported on watchOS because XCUITest cannot drive watchOS UI.`}),Bs=Q(`screenshot is supported only for Apple simulators and devices.`),Vs=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`Open the app under test before capturing its snapshot.`});function Q(e){return Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:e})}function Hs(e){return!g(e)||e.appleOs===`watchos`?Z:e.kind===`simulator`?X:Is}function Us(e){let t=Ws(e),n=Gs(e),r=Ks(e),i=qs(e);return ge({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:i,clearRuntimeHints:i,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:n,configureProviderPortReverse:Fs})}function Ws(e){return u(e)===`watchos`?Os:e.kind===`simulator`||e.kind===`device`?X:Ms}function Gs(e){return u(e)===`watchos`?ks:e.kind===`simulator`||e.kind===`device`?X:Ns}function Ks(e){return u(e)===`watchos`?As:e.kind===`simulator`||e.kind===`device`?X:Ps}function qs(e){return u(e)!==`watchos`&&g(e)&&e.kind===`simulator`?X:js}function Js(e){return e.appleOs===`watchos`?Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS app inventory is not supported.`}):e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`App inventory is available only on CoreDevice-backed physical iOS devices.`}):X}function $(e){return e.kind===`simulator`||e.kind===`device`?X:Ss}function Ys(e){let t=Xn(e),n=ns(e),r,i=e=>h(e)?r??=Zt():`xctest`,a=async n=>{let r=await t.inspectFacts(n),a=fa(n),o=Rr(n),s=o.available?await e.screenRecording.apple.availability(n):void 0,c=o.available&&s?.available===!1?Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:s.hint}):o,l=n.appleOs===`watchos`?Z:X,u=h(n)||n.appleOs===`watchos`?Z:X,d=Js(n);return Object.freeze({device:r.device,operations:{...r.operations,...a,appState:ws(n),networkDump:X,screenRecordingStart:c,screenRecordingReattach:c,screenRecordingCleanup:c,...ec(n),...Te({capture:$s(n)}),...je({findText:Qs(n)}),...ve({setViewport:ys}),...He({focus:$(n)}),...bn(n),..._e({type:$(n)}),...Ge({unsupported:Z,tap:$(n),longPress:$(n),fill:$(n),...g(n)?{tapElementSelector:$(n)}:{}}),...be({readTextAtPoint:Zs(n)}),...Ua(n),...Bo(n),...ao(n),...Ue({capture:pn(n),query:bs}),...We(Xs(n)),ensureReady:l,bootTarget:u,bootTargetHeadless:Ts,listApps:d,...Us(n),shutdownTarget:Hs(n),...Ko(n,i(n))}})};return Object.freeze({owner:Y,ownsDevice:e=>e.platform===`apple`,inspectFacts:a,bind:async r=>{let o=await t.bind(r),s=await a(r.device),c=s.operations.screenRecordingStart,l={..._(s.operations.appState,()=>fn(e,{device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),...o.operations,...pa({host:e,device:r.device,signal:r.scope.signal}),networkDump:async t=>await er(e,r.device,t,r.scope.signal),..._(c,()=>zr({host:e,device:r.device,owner:Y,signal:r.scope.signal})),..._(s.operations.audioProbeStart,()=>tt({host:e.audioProbe.hostCapture,device:r.device,owner:Y})),..._(s.operations.perfFrames,()=>mn({resolveHost:()=>e.perf.apple,device:r.device,owner:Y})),..._(s.operations.captureSnapshot,()=>Ho(e,{device:r.device,signal:r.scope.signal,appBackend:i(r.device)},n)),..._(s.operations.captureScreenshot,()=>Ee({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),..._(s.operations.focusPoint,()=>De({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),...Ae({device:r.device,signal:r.scope.signal,facts:s.operations,resolveInteractor:e.localInteractors.resolve}),..._(s.operations.scrollDirection,()=>Fe({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),..._(s.operations.typeText,()=>ke({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),..._(s.operations.tapPoint,()=>Ke({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve,facts:s.operations,pause:async t=>await e.clock.sleep(t,r.scope.signal)})),..._(s.operations.readTextAtPoint,()=>xe({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),..._(s.operations.findText,()=>Uo(e,{device:r.device,signal:r.scope.signal,appBackend:i(r.device)})),...Wa({host:e,device:r.device,signal:r.scope.signal,admitted:s.operations}),...oo({host:e,device:r.device,signal:r.scope.signal}),...Vo({device:r.device,signal:r.scope.signal}),..._(s.operations.ensureReady,()=>({ensureReady:async()=>await F(e,r.device,r.scope.signal)})),..._(s.operations.bootTarget,()=>({bootTarget:async t=>await F(e,r.device,r.scope.signal,{deadlineAtMs:t.deadlineAtMs})})),..._(s.operations.listApps,()=>({listApps:async e=>{r.scope.signal.throwIfAborted();let{listIosApps:t}=await import(`./app-resolution.js`).then(e=>e.t);return(await t(e.device,e.filter)).map(e=>({id:e.bundleId,name:e.name}))}})),...me(Ri({host:e,device:r.device,signal:r.scope.signal,observation:n}),s.operations),..._(s.operations.shutdownTarget,()=>({shutdownTarget:async()=>await e.deviceShutdown.apple.shutdownTarget(r.device,r.scope.signal)}))};return Object.freeze({device:o.device,owner:Y,facts:s,operations:dn(l),[Symbol.asyncDispose]:async()=>await o[Symbol.asyncDispose]()})},shutdown:async()=>{await Promise.all([t.shutdown(),n.shutdown()])}})}function Xs(e){let t=e.iosPhysicalDeviceBackend!==`xctest`&&u(e)!==`watchos`?X:xs;return{frames:t,memorySample:t,memorySnapshot:t,nativeCapture:t,profileReport:t}}function Zs(e){return u(e)===`watchos`?Es:e.kind===`simulator`||e.kind===`device`?X:Ds}function Qs(e){return u(e)===`watchos`?Ls:e.kind===`simulator`||e.kind===`device`?X:Ls}function $s(e){return u(e)===`watchos`?zs:e.kind===`simulator`||e.kind===`device`?X:Bs}function ec(e){let t=Qs(e);return Se({capture:t,customActions:t.available&&g(e)&&e.kind===`simulator`?X:Rs,withoutActiveApp:g(e)?Vs:t})}export{Ys as createApplePlatformRuntime};
|
|
1
|
+
import{J as e}from"./sdk-contracts.js";import{n as t}from"./ime-state.js";function n(e){return Object.freeze({canShutdownTarget:r,shutdownTarget:async(t,n)=>await i(e.commands,t,n)})}function r(e){return e.platform===`android`&&e.kind===`emulator`}async function i(n,r,i){if(r.booted===!1)return a();i.throwIfAborted(),await t(r.id,i),i.throwIfAborted();try{let e=await n.run({executable:`adb`,args:[`-s`,r.id,`emu`,`kill`],allowFailure:!0,timeoutMs:15e3},i);i.throwIfAborted();let t=e.exitCode??-1;return{success:t===0,exitCode:t,stdout:e.stdout,stderr:e.stderr}}catch(t){i.throwIfAborted();let n=e(t);return{success:!1,exitCode:-1,stdout:``,stderr:n.message,error:n}}}function a(){return{success:!0,exitCode:0,stdout:``,stderr:``}}export{n as createAndroidShutdownRuntime};
|
package/dist/src/runtime5.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
import{J as e}from"./sdk-contracts.js";import{p as t}from"./sdk-device.js";import{o as n}from"./simctl.js";import{t as r}from"./simulator-state.js";const i=15e3;function a(e){return Object.freeze({canShutdownTarget:o,shutdownTarget:async(t,n)=>await s(e.appleTools,t,n)})}function o(e){return t(e)&&e.appleOs!==`watchos`&&e.kind===`simulator`}async function s(t,r,a){a.throwIfAborted();try{let e=await t.run({tool:`simctl`,args:n(r,[`shutdown`,r.id]),allowFailure:!0,timeoutMs:i},a);a.throwIfAborted();let o=l(e);return o.success?o:await c(t,r,a)===`Shutdown`?{...o,success:!0,exitCode:0}:o}catch(t){a.throwIfAborted();let n=e(t);return{success:!1,exitCode:-1,stdout:``,stderr:n.message,error:n}}}async function c(e,t,n){try{return await r(e,t,n,i)}catch{return n.throwIfAborted(),null}}function l(e){let t=e.exitCode??-1;return{success:t===0,exitCode:t,stdout:e.stdout,stderr:e.stderr}}export{a as createAppleShutdownRuntime};
|
|
1
|
+
import{F as e,I as t,J as n,K as r,P as i}from"./sdk-contracts.js";import{a,i as o,v as s}from"./sdk-batch-runner.js";import{c,r as l}from"./diagnostics.js";import"./diagnostics2.js";import{A as u,N as d,f,g as p,h as m,l as h,m as ee,x as te}from"./sdk-device.js";import{Xt as ne,in as re,nn as g,rn as _,tn as ie}from"./sdk-batch.js";import{n as ae,r as oe}from"./session.js";import"./device.js";import{a as se,u as v}from"./device-rotation.js";import{o as ce,r as y}from"./exec.js";import"./command.js";import{r as le}from"./version.js";import{n as ue}from"./scoped-provider.js";import{i as de,n as fe,r as pe}from"./ios-snapshot-planning.js";import{t as me}from"./request.js";import{n as he,r as ge,t as _e}from"./application-lifecycle-runtime.js";import{A as ve,B as ye,C as be,D as xe,E as Se,G as Ce,H as we,I as Te,J as Ee,K as De,L as Oe,N as ke,O as Ae,P as je,V as Me,W as Ne,d as Pe,h as Fe,j as Ie,n as Le,o as Re,s as ze,v as Be,w as Ve,x as He,z as Ue}from"./alert-runtime.js";import{n as We}from"./audio-probe-runtime.js";import{n as Ge}from"./perf-runtime.js";import{i as Ke,t as qe}from"./touch-runtime.js";import{a as Je,n as Ye}from"./durable-resource.js";import{n as Xe,t as Ze}from"./async-lifecycle.js";import{a as Qe,c as $e,d as et,f as tt,l as nt,n as rt,o as it,s as at,t as ot,u as st}from"./src7.js";import{n as ct,t as lt}from"./screen-recording-completion.js";import{a as ut,c as dt,i as ft,n as pt,o as mt,r as ht,s as gt,t as _t}from"./device-readiness-runtime.js";import{n as vt}from"./screen-recording-runtime.js";import{t as yt}from"./ios-system-surface.js";import{i as bt,r as xt}from"./gesture-admission.js";import{t as St}from"./interactor-operation-catalog.js";import{a as Ct,i as wt,n as Tt,r as Et,t as Dt}from"./perf-runtime-operation-builder.js";import{t as Ot}from"./app-log-runtime.js";import{n as kt}from"./artifact-paths.js";import{i as At,r as jt}from"./managed-device-scope.js";import{n as Mt,o as Nt,s as Pt}from"./application-lifecycle-interaction.js";import{f as Ft}from"./host-file.js";import{a as It,o as Lt,s as Rt}from"./config.js";import{a as zt,o as Bt}from"./tool-provider.js";import{o as Vt}from"./devicectl.js";import{t as Ht}from"./physical-device-apps.js";import{t as Ut}from"./apple-runner-platform.js";import{a as Wt,c as Gt,n as Kt,o as qt,s as b,u as Jt}from"./simctl.js";import{a as Yt,r as Xt}from"./simulator.js";import{r as Zt}from"./display-inventory.js";import{n as Qt,t as $t}from"./app-backend.js";import{t as en}from"./simulator-state.js";import{a as tn,c as nn,d as rn,i as an,l as on,n as sn,o as cn,r as ln,t as un,u as dn}from"./cache.js";import{randomUUID as fn}from"node:crypto";import x from"node:path";function pn(e){let t=At();return Object.freeze(t?{...ue({...e},e=>Yt(t,e))}:e)}function mn(e,t){return Object.freeze({appState:async n=>{if(t.signal.throwIfAborted(),!await e.appleApplications.hasLiveRunnerSession(t.device,{}))return{};let r=await t.resolveInteractor(t.device,{appBundleId:n?.appBundleId,signal:t.signal});if(typeof r.appState!=`function`)throw re(`Runtime owner advertised appState without an interactor implementation`);return await r.appState()}})}function hn(e){return mt(e)?Object.freeze({available:!0}):p(e)||m(e)&&e.kind===`simulator`?Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`audio probe capture requires a macOS host.`}):Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`audio is supported for macOS sessions and iOS simulators on macOS hosts; physical iOS devices expose no host audio tap.`})}function gn(e){let{resolveHost:t,device:n,owner:r}=e;return Object.freeze({...Dt({platform:`Apple`,expectedProfileKind:`xctrace`,start:async e=>await t().start(n,r,e),reattach:async e=>await t().reattach(n,e),cleanup:async e=>await t().cleanup(n,e),writeProfileReport:async e=>await t().writeProfileReport(e)}),perfFrames:async({appId:e})=>({metric:e?await wt(t().sampleFrames(n,e)):Tt(`Apple`,`bundle ID`),sampling:await t().frameSampling(n)}),perfMemorySample:async({appId:e})=>({metric:e?await wt(t().sampleMemory(n,e)):Tt(`Apple`,`bundle ID`),sampling:await t().memorySampling(n)}),perfMemorySnapshot:async({appId:e,kind:r,outPath:i,artifactsDir:a})=>{let o=r??`memgraph`,s={...await t().memorySnapshotSupport(n),androidHprof:!1,heapprofd:!1};if(o!==`memgraph`)return Ct(`Apple`,o,s,`Use perf memory snapshot --kind memgraph for supported Apple app sessions.`);if(!e)throw Et();let c=i??x.join(a,`memory-memgraph-${_n()}.memgraph`);return{artifact:await t().captureMemorySnapshot(n,e,c),support:s,sampling:{method:`xcrun memgraph`,description:`Native Apple memory graph captured for offline inspection.`,defaultKind:`memgraph`,artifactOnly:!0}}}})}function _n(){return new Date().toISOString().replaceAll(/[:.]/g,`-`)}const S=Object.freeze({available:!0}),C=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),w=xn(`Gestures are supported only for Apple simulators and devices.`),vn=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:xt}),yn=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:bt}),bn=xn(`scroll is supported only for Apple simulators and devices.`);function xn(e){return Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:e})}function Sn(e){return{...Te({unsupported:Cn(e),plan:wn(e),directionalFling:wn(e),multiTouch:Tn(e),targetAuthoredDrag:En(e),viewport:Dn(e)}),...ke({scroll:On(e)})}}function Cn(e){return e.appleOs===`watchos`||e.appleOs===`visionos`?C:w}function wn(e){return e.appleOs===`watchos`||e.appleOs===`visionos`?C:T(e)?S:w}function Tn(e){if(e.appleOs===`watchos`)return C;if(!T(e))return w;let t=u(e);if(t!==`ios`&&t!==`ipados`){let e=Qt[t];return Object.freeze({available:!1,reason:`unsupported-platform-leaf`,...e===void 0?{}:{hint:e}})}return e.kind===`simulator`?S:vn}function En(e){return T(e)?(e.appleOs===void 0?e.target!==`desktop`&&e.target!==`tv`:e.appleOs===`ios`||e.appleOs===`ipados`)?S:yn:w}function Dn(e){return e.appleOs===`watchos`?C:T(e)?S:w}function On(e){return T(e)?S:bn}function T(e){return e.kind===`simulator`||e.kind===`device`}const E=`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`;function D(e){return p(e)?`macos`:e.kind===`device`?`ios-device`:`ios-simulator`}const kn=Object.freeze({resourceKind:Ot,version:1,encode:e=>({...e}),decode:e=>!jn(e.transport)||!Mn(e.backend)||!In(e.outputPath)||!Pn(e.pidPath)||!Nn(e.transport,e.backend)?An():{status:`decoded`,descriptor:Object.freeze({transport:e.transport,backend:e.backend,outputPath:e.outputPath,...e.pidPath===void 0?{}:{pidPath:e.pidPath}})}});function An(){return{status:`invalid`,message:`Invalid Apple app-log descriptor`}}function jn(e){return e===`apple-log-stream`||e===`coredevice-console`}function Mn(e){return e===`ios-simulator`||e===`ios-device`||e===`macos`}function Nn(e,t){return e===`coredevice-console`?t===`ios-device`:t!==`ios-device`}function Pn(e){return e===void 0||In(e)}function Fn(e){if(!e.device.appleOs)throw TypeError(`Apple app-log persistence requires an explicit appleOs identity`);return Ye({resourceKind:Ot,sessionId:e.sessionId,device:{id:e.device.id,family:`apple`,appleOs:e.device.appleOs,kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target},...e.device.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.device.iosPhysicalDeviceBackend}},owner:e.owner,fence:e.fence,lifecycle:`open`,descriptor:Je(kn,e.descriptor)})}function In(e){return typeof e==`string`&&e.trim().length>0}const Ln={message:`iOS physical-device app console capture is not supported by the installed devicectl.`,hint:`This devicectl does not expose process launch --console. Markers can still be written to app.log, but app output is not being captured. Use an iOS simulator for agent-device app logs or inspect physical-device logs in Console.app/Xcode until this Xcode toolchain exposes scriptable console capture.`},Rn={message:`Could not verify iOS physical-device app console capture support.`,hint:`Retry logs clear --restart. If the probe keeps failing, run logs doctor and inspect the request diagnostics for the devicectl help command.`};async function zn(e,t){try{let n=await e.appleTools.run({tool:`devicectl`,args:[`device`,`process`,`launch`,`--help`],allowFailure:!0,timeoutMs:5e3},t),r=n.stderr.trim()||void 0;if(n.exitCode!==0)return{supported:!1,reason:`probe-failed`,stderr:r};let i=`${n.stdout}\n${n.stderr}`;return/\bUSAGE:\s+devicectl device process launch\b/i.test(i)&&/--console\b/.test(i)&&/--terminate-existing\b/.test(i)?{supported:!0,...r?{stderr:r}:{}}:{supported:!1,reason:`unsupported`,...r?{stderr:r}:{}}}catch(e){if(t?.aborted)throw t.reason;return{supported:!1,reason:`probe-failed`,...e instanceof Error?{stderr:e.message}:{}}}}async function Bn(e,t,n,r){let i={},a=n?[]:[`No app bundle is tracked in this session. Run open <app> first for app-scoped logs.`];if(p(t))i.logAvailable=!!await e.commands.which(`log`);else if(t.kind===`simulator`)i.simctlAvailable=await dt(async()=>gt(await e.appleTools.run({tool:`simctl`,args:Gt(),allowFailure:!0},r)),r);else if(t.iosPhysicalDeviceBackend===`xctest`)i.devicectlAvailable=!1,i.devicectlConsoleCapture=!1,a.push(E);else{i.devicectlAvailable=await dt(async()=>gt(await e.appleTools.run({tool:`devicectl`,args:[`--version`],allowFailure:!0},r)),r);let t=await zn(e,r);if(i.devicectlConsoleCapture=t.supported,!t.supported){let e=t.reason===`unsupported`?Ln:Rn;a.push(`${e.message} ${e.hint}`)}}return{backend:D(t),checks:i,notes:a}}function Vn(e,t){let n=Wn(e),r=[`subsystem == "${n}"`,`subsystem CONTAINS "${n}"`,`processImagePath ENDSWITH[c] "/${n}"`,`senderImagePath ENDSWITH[c] "/${n}"`];if(t){let e=Wn(t);r.push(`process == "${e}"`,`processImagePath ENDSWITH[c] "/${e}"`,`senderImagePath ENDSWITH[c] "/${e}"`,`processImagePath CONTAINS[c] "/${e}.app/"`,`senderImagePath CONTAINS[c] "/${e}.app/"`)}return r.join(` OR `)}function Hn(e,t){return Kt(e,[`spawn`,e.id,`log`,`stream`,`--style`,`compact`,`--level`,`info`,`--predicate`,Vn(t.appBundleId,t.executableName)])}function Un(e,t){return[`devicectl`,`device`,`process`,`launch`,`--device`,e,`--console`,`--terminate-existing`,t]}function Wn(e){return e.replaceAll(`\\`,String.raw`\\`).replaceAll(`"`,String.raw`\"`)}async function Gn(e,t,n,r,i){Kn(t),it(e,n);let a=D(t),o=await Jn(e,t,n.appBundleId,i),s=new Ze,c=!1;try{let l=await e.outputs.openAppend(n.outputPath);s.defer(async()=>{c||await l[Symbol.asyncDispose]()}),i?.throwIfAborted();let u=await qn(e,t,o,l,n.pidPath,i);s.defer(async()=>{c||await u[Symbol.asyncDispose]()});let d=Xn(e,u,l,a,n.outputPath),f={transport:a===`ios-device`?`coredevice-console`:`apple-log-stream`,backend:a,outputPath:n.outputPath,...n.pidPath===void 0?{}:{pidPath:n.pidPath}},p=tt(d,Fn({sessionId:n.sessionId,device:t,owner:r,fence:n.fence,descriptor:f}));return c=!0,p}finally{await s[Symbol.asyncDispose]()}}function Kn(e){if(e.appleOs===`watchos`)throw new i(`UNSUPPORTED_PLATFORM`,`watchOS app logs are not supported`);if(m(e)&&e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`)throw new i(`UNSUPPORTED_OPERATION`,E,{hint:E})}async function qn(e,t,n,r,a,o){if(m(t)&&t.kind===`device`){let t=await zn(e,o);if(!t.supported){let e=t.reason===`unsupported`?Ln:Rn;throw new i(t.reason===`unsupported`?`UNSUPPORTED_OPERATION`:`COMMAND_FAILED`,e.message,{backend:`ios-device`,hint:e.hint,stderr:t.stderr})}}return o?.throwIfAborted(),await e.processes.start({command:{kind:`host`,request:n},output:r,...a?{markerPath:a}:{}})}async function Jn(e,t,n,r){return p(t)?{executable:`log`,args:[`stream`,`--style`,`compact`,`--predicate`,Vn(n)],allowFailure:!0}:t.kind===`device`?{executable:`xcrun`,args:Un(t.id,n),allowFailure:!0}:{executable:`xcrun`,args:Hn(t,{appBundleId:n,executableName:await Yn(e,t,n,r)}),allowFailure:!0}}async function Yn(e,t,n,r){let i=await e.appleTools.run({tool:`simctl`,args:b(t,[`get_app_container`,t.id,n,`app`]),allowFailure:!0,timeoutMs:4e3},r),a=i.exitCode===0?i.stdout.trim():``;if(!a)return;let o=await e.commands.run({executable:`plutil`,args:[`-extract`,`CFBundleExecutable`,`raw`,`-o`,`-`,x.join(a,`Info.plist`)],allowFailure:!0,timeoutMs:4e3},r);return o.exitCode===0&&o.stdout.trim()||void 0}function Xn(e,t,n,r,i){let a=e.clock.now(),o=`active`;t.wait.then(e=>{o=e.exitCode===0?`ended`:`failed`},()=>{o=`failed`});let s;return st({inspect:()=>({backend:r,state:o,startedAt:a}),finish:async()=>s??=(async()=>(await Zn([async()=>await t.terminate(),async()=>await t.wait.then(()=>void 0),async()=>await t[Symbol.asyncDispose](),async()=>await n[Symbol.asyncDispose]()])).length>0?(o=`failed`,{status:`cleanup-pending`,reason:`transport-failed`,message:`Apple app-log cleanup did not settle every owned resource`}):(o=`ended`,{status:`completed`,result:{backend:r,outputPath:i,completedAt:e.clock.now()}}))()})}async function Zn(e){let t=[];for(let n of e)try{await n()}catch(e){t.push(e)}return t}const O=ne(`apple`),Qn=Object.freeze({available:!0});function $n(e){return Object.freeze({owner:O,ownsDevice:e=>e.platform===`apple`,inspectFacts:async e=>tr(e),bind:async t=>{if(t.intent.kind===`exact-owner`&&!ie(t.intent.owner,O))throw new i(`UNSUPPORTED_OPERATION`,`Apple app-log owner identity does not match`);return er(e,t.device,t.scope.signal)},shutdown:async()=>void 0})}function er(e,t,n){if(t.platform!==`apple`)throw new i(`UNSUPPORTED_PLATFORM`,`Apple app-log owner cannot bind ${t.platform}`);let r=et({codec:kn,reattach:async(n,r)=>n.backend!==D(t)||!Qe(e,r.sessionId,n)?{status:`unreattachable`,reason:`descriptor-invalid`,message:`Apple app-log descriptor does not match the bound device or owning session`}:await $e(e,n.pidPath),cleanup:async(n,r)=>n.backend===D(t)&&Qe(e,r.sessionId,n)?await at(e,n.pidPath):{status:`cleanup-pending`,reason:`ownership-fence-lost`,message:`Apple app-log descriptor does not match the bound device or owning session`}}),a=Object.freeze({appLogInspect:async()=>({backend:D(t)}),appLogDoctor:async({appBundleId:r})=>await Bn(e,t,r,n),appLogStart:async r=>await Gn(e,t,r,O,n),...r});return Object.freeze({device:t,owner:O,facts:tr(t),operations:a,[Symbol.asyncDispose]:async()=>void 0})}function tr(e){if(e.appleOs===`watchos`)return nr(e);let t=m(e)&&e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?{available:!1,reason:`unsupported-device-backend`,hint:E}:Qn;return Object.freeze({device:{family:`apple`,appleOs:e.appleOs,kind:e.kind,...e.target===void 0?{}:{target:e.target},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend},providerMode:`local`},operations:{appLogInspect:t,appLogDoctor:t,appLogStart:t,appLogReattach:Qn,appLogCleanup:Qn}})}function nr(e){let t=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS app logs are not supported.`});return Object.freeze({device:{family:`apple`,appleOs:`watchos`,kind:e.kind,...e.target===void 0?{}:{target:e.target},providerMode:`local`},operations:{appLogInspect:t,appLogDoctor:t,appLogStart:t,appLogReattach:t,appLogCleanup:t}})}async function rr(e,t,n,r){let i=D(t),a=await e.appLogs.readRecent(n.sessionId,n.maxScanLines),o=rt(a.text,{...n,path:a.path,exists:a.exists,lineNumberOffset:a.skippedLines,backend:i}),s=[];if(ar(t,n,o.dump)){let i=await or(e,t,n,a.path,r);i&&(o=ir(s,o,i,n.maxEntries))}return lr(s,t,n),cr(s,o.dump),o.dump.entries.length===0&&s.push(ur(t)),Object.freeze({source:`app-log`,backend:i,dump:o.dump,notes:Object.freeze(s)})}function ir(e,t,n,r){let i=n.scan.dump.entries.length;return i===0&&(n.scan.dump.unnamedRequests??0)===0?(n.lineCount>0&&e.push(`Recovered ${n.lineCount} recent iOS simulator app log lines from simctl log show, but none looked like HTTP traffic. This app may not emit request URLs, status, or timing into Unified Logging for this repro window.`),t):(i>0&&e.push(`Recovered ${i} iOS simulator HTTP entr${i===1?`y`:`ies`} from simctl log show (${n.lineCount} app log lines scanned).`),ot(n.scan,t,r))}function ar(e,t,n){return m(e)&&e.kind===`simulator`&&!!t.appBundleId&&n.entries.length===0}async function or(e,t,n,r,i){let a=n.appLogSnapshot?.startedAt,o=b(t,[`spawn`,t.id,`log`,`show`,`--style`,`compact`,`--info`,`--predicate`,sr(n.appBundleId),...typeof a==`number`&&Number.isFinite(a)&&a>0?[`--start`,`@${Math.floor(a/1e3)}`]:[`--last`,`5m`]]),s=await e.appleTools.run({tool:`simctl`,args:o,allowFailure:!0,timeoutMs:4e3},i);if(s.exitCode!==0||!s.stdout.trim())return;let c=s.stdout.split(`
|
|
2
|
+
`).map(e=>e.trimEnd()).filter(e=>e.trim()&&!e.trim().startsWith(`Timestamp Ty Process[PID:TID]`));if(c.length!==0)return{scan:rt(`${c.join(`
|
|
3
|
+
`)}\n`,{...n,path:`${r} (simctl log show recovery)`,exists:!0,backend:`ios-simulator`}),lineCount:c.length}}function sr(e){let t=e.replaceAll(`\\`,String.raw`\\`).replaceAll(`"`,String.raw`\"`);return[`subsystem == "${t}"`,`subsystem CONTAINS "${t}"`,`processImagePath ENDSWITH[c] "/${t}"`,`senderImagePath ENDSWITH[c] "/${t}"`].join(` OR `)}function cr(e,t){let n=t.entries.filter(e=>e.pathUnavailable).length,r=t.unnamedRequests??0,i=n+r;if(i===0)return;let a=[`${i} request${i===1?``:`s`} reused a keep-alive connection, so CFNetwork logged no request URL.`];n>0&&a.push(`${n} listed against the origin the connection was opened for, without a path.`),r>0&&a.push(`${r} opened before this scan window and are missing from the entries entirely; scan more lines, or run logs clear --restart before the repro.`),a.push(`Absence of an endpoint in this dump does not prove it was not called.`),e.push(a.join(` `))}function lr(e,t,n){n.appLogSnapshot?n.appLogSnapshot.state!==`active`&&e.length===0&&e.push(m(t)&&t.kind===`simulator`?`Session app log stream is inactive. The iOS simulator recovery path scanned recent simctl log history, but a fresh logs clear --restart window is still the most reliable repro loop.`:`Session app log stream is inactive. Run logs clear --restart, reproduce the request window again, then rerun network dump.`):e.push(`Capture uses the session app log file. For fresh traffic, run logs clear --restart before reproducing requests.`)}function ur(e){return m(e)&&e.kind===`simulator`?`No HTTP(s) entries were found in recent iOS simulator app logs. If the app only emits non-HTTP diagnostics, inspect logs path or add app-side URLSession/network logging for per-request timing and payload details.`:m(e)?`No HTTP(s) entries were found in recent iOS device app logs. iOS network dump only sees what the app emits into Unified Logging for this process.`:`No HTTP(s) entries were found in recent session app logs.`}async function dr(t){let{host:n,snapshot:r,targetLabel:i,recorderWarning:a,nativePathDisposition:o}=t,s=r.invalidatedReason?{recorder:`lost`,why:`owner-session-lost`}:t.stopObservation;if(r.invalidatedReason&&!r.showTouches)throw Error(`recording invalidated: ${r.invalidatedReason}`);let c;try{c=await n.screenRecording.finalize.complete({outputPath:r.outPath,showTouches:!r.invalidatedReason&&r.showTouches,gestureEvents:r.gestureEvents,exportQuality:r.exportQuality??`medium`,...r.fps===void 0?{}:{fps:r.fps},targetLabel:i})}catch(t){throw e(t,`COMMAND_FAILED`)}let l=[...c.warning?[c.warning]:[],...a?[a]:[]];return lt(r,{...c,...l.length>0?{warning:l.join(` `)}:{},...r.invalidatedReason?{overlayWarning:`overlay unavailable: ${r.invalidatedReason}`}:{}},{stopObservation:s,...o===void 0?{}:{nativePathDisposition:o}})}async function fr(e){let{host:t,snapshot:n,targetLabel:r,collectedPath:i,exportPath:a,nativePath:o}=e;if(n.invalidatedReason&&!n.showTouches)throw Error(`recording invalidated: ${n.invalidatedReason}`);let s=e.overlayUnavailable??n.invalidatedReason,c;try{await t.screenRecording.outputs.copy({from:i,to:a}),c=await pr(()=>t.screenRecording.finalize.complete({outputPath:a,showTouches:s===void 0&&n.showTouches,gestureEvents:n.gestureEvents,exportQuality:n.exportQuality??`medium`,...n.fps===void 0?{}:{fps:n.fps},targetLabel:r}))}catch(e){throw await t.screenRecording.outputs.remove(a),e}return{...c,...s===void 0?{}:{overlayWarning:`overlay unavailable: ${s}`},nativePathDisposition:await t.screenRecording.outputs.remove(o)===`removed`?`retired`:`retirable`}}async function pr(t){try{return await t()}catch(t){throw e(t,`COMMAND_FAILED`)}}const mr=[`outPath`,`startedAt`,`clientOutPath`,...ft],hr=Object.freeze({resourceKind:vt,version:1,encode:e=>e.backend===`simctl`?{backend:e.backend,outputPath:e.outputPath,processes:e.processes.map(e=>({...e})),...e.recording===void 0?{}:{recording:{...e.recording}}}:{backend:e.backend,outputPath:e.outputPath,appBundleId:e.appBundleId,runnerSessionId:e.runnerSessionId,runnerAuthority:e.runnerAuthority,...e.remotePath===void 0?{}:{remotePath:e.remotePath}},decode:e=>Dr(e)});function gr(e){let{device:t,owner:n,input:r,descriptor:i}=e;return Ye({resourceKind:vt,sessionId:r.sessionId,device:d(t),owner:n,fence:r.fence,lifecycle:`open`,descriptor:Je(hr,i)})}function _r(e){let t={};for(let n of mr)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}async function vr(e,t,n,r){let i=hr.decode(n);return i.status!==`decoded`||!Lr(t,i.descriptor)?{status:`cleanup-pending`,reason:`manual-recovery-required`}:i.descriptor.backend===`simctl`?await yr(e,i.descriptor.processes,r):await xr(e,t,i.descriptor)}async function yr(e,t,n){let r=await Promise.all(t.map(async t=>await e.screenRecording.apple.inspectProcess(t)));if(r.includes(`ownership-lost`))return{status:`cleanup-pending`,reason:`ownership-fence-lost`};if(r.every(e=>e===`missing`))return n!==void 0&&e.screenRecording.ownedProcesses.clear(br(n)),{status:`already-missing`};let i=await Promise.all(t.flatMap((t,n)=>r[n]===`owned-alive`?[e.screenRecording.apple.terminateProcess(t)]:[]));return i.includes(`ownership-lost`)?{status:`cleanup-pending`,reason:`ownership-fence-lost`}:(n!==void 0&&e.screenRecording.ownedProcesses.clear(br(n)),i.every(e=>e===`already-missing`)?{status:`already-missing`}:{status:`cleaned`})}function br(e){return{kind:`session`,sessionId:e}}async function xr(e,t,n){try{let r=await e.screenRecording.apple.inspectRunner(t,n.runnerSessionId,n.runnerAuthority);return r===`missing`?{status:`already-missing`}:r===`ownership-lost`?{status:`cleanup-pending`,reason:`ownership-fence-lost`}:(await e.screenRecording.apple.runRunner(t,{kind:`stop`,appBundleId:n.appBundleId,runnerSessionId:n.runnerSessionId,runnerAuthority:n.runnerAuthority}),{status:`cleaned`})}catch(e){return{status:`cleanup-pending`,reason:`transport-failed`,message:e instanceof Error?e.message:`Apple recording cleanup failed`}}}async function Sr(e){let{host:t,device:n,envelope:r}=e,i=hr.decode(r.descriptor.body);return i.status===`decoded`?Lr(n,i.descriptor)?i.descriptor.backend===`simctl`?await Cr(e,i.descriptor):await Tr(t,n,i.descriptor):k(`descriptor-invalid`,`Apple screen-recording descriptor does not match the bound device.`):k(`descriptor-invalid`,i.message)}async function Cr(e,t){let n=await Promise.all(t.processes.map(async t=>await e.host.screenRecording.apple.inspectProcess(t)));if(!n.every(e=>e===`missing`))return k(`transport-not-reattachable`,n.includes(`ownership-lost`)?`Apple recording ownership no longer matches the durable descriptor.`:`Apple screen recordings require exact cleanup after daemon restart.`);let{recording:r}=t,i=wr(ht(e.envelope.metadata),t.outputPath);return r===void 0||i!==void 0&&!await Er(e.host,i)?{status:`missing`}:{status:`restore-export`,recording:r,nativePath:t.outputPath,cleanup:async()=>await yr(e.host,t.processes,e.envelope.sessionId)}}function wr(e,t){if(e.finalization===void 0)return e.collectedPath??t}async function Tr(e,t,n){let r=await e.screenRecording.apple.inspectRunner(t,n.runnerSessionId,n.runnerAuthority);return r===`missing`?{status:`missing`}:k(`transport-not-reattachable`,r===`ownership-lost`?`Apple recording ownership no longer matches the durable descriptor.`:`Apple screen recordings require exact cleanup after daemon restart.`)}async function Er(e,t){try{return await e.screenRecording.finalize.sniff({outputPath:t}),!0}catch{return!1}}function k(e,t){return{status:`unreattachable`,reason:e,message:t}}function Dr(e){return typeof e.outputPath!=`string`||e.outputPath.length===0?j():e.backend===`simctl`?Or(e,e.outputPath):e.backend===`runner`?jr(e,e.outputPath):j()}function Or(e,t){let n=Rr(e.processes),r=kr(e.recording);return!n||r===`invalid`?j():{status:`decoded`,descriptor:Object.freeze({backend:`simctl`,outputPath:t,processes:n,...r===void 0?{}:{recording:r}})}}function kr(e){if(e!==void 0)return s(e)&&Ar(e)?Object.freeze(e):`invalid`}function Ar(e){return A(e.outPath)&&Nr(e.startedAt)&&Mr(e.clientOutPath)&&ut(e)}function jr(e,t){return!A(e.appBundleId)||!A(e.runnerSessionId)||!Pr(e.runnerAuthority)||!Fr(e.remotePath)?j():{status:`decoded`,descriptor:Object.freeze({backend:`runner`,outputPath:t,appBundleId:e.appBundleId,runnerSessionId:e.runnerSessionId,runnerAuthority:e.runnerAuthority,...e.remotePath===void 0?{}:{remotePath:e.remotePath}})}}function A(e){return typeof e==`string`&&e.length>0}function Mr(e){return e===void 0||A(e)}function Nr(e){return typeof e==`number`&&Number.isFinite(e)}function Pr(e){return e===`local-lease`||e===`scoped-provider`}function Fr(e){return e===void 0||Ir(e)}function Ir(e){return typeof e==`string`&&/^tmp\/agent-device-recording-\d+\.mp4$/.test(e)}function Lr(e,t){return e.kind===`simulator`?t.backend===`simctl`:t.backend===`runner`?e.appleOs===`macos`?t.remotePath===void 0:m(e)?t.remotePath!==void 0&&Ir(t.remotePath):t.remotePath===void 0:!1}function Rr(e){if(!Array.isArray(e)||e.length===0)return;let t=e.filter(e=>typeof e==`object`&&!!e&&Number.isInteger(e.pid)&&(e.pid??0)>0&&typeof e.startTime==`string`&&e.startTime.length>0&&typeof e.command==`string`&&e.command.length>0);return t.length===e.length?Object.freeze([...t]):void 0}function j(){return{status:`invalid`,message:`Invalid Apple screen-recording descriptor`}}async function zr(e,t,n){if(e.kind!==`simulator`||t.scope!==`app`)return;let r=t.activeSessionApp?.bundleId;if(!r)throw TypeError(`App-scoped recording requires an active app session; open the app under test before recording.`);if(await n(r))throw TypeError(`App-scoped recording requires a real application session; open the app under test before recording.`)}const Br=`iOS recording`,Vr=`simctl recordVideo`;function Hr(e){return e.appleOs===`watchos`?g(`unsupported-platform-leaf`,`watchOS recording is not supported.`):m(e)&&e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?g(`unsupported-device-backend`,`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`):Object.freeze({available:!0})}function Ur(e){let{host:t,device:n,owner:r,signal:i}=e;return Object.freeze({screenRecordingStart:async e=>await Wr({host:t,device:n,owner:r,input:e,signal:i}),screenRecordingReattach:async e=>{let r=await Sr({host:t,device:n,envelope:e.envelope});return r.status===`restore-export`?{status:`active`,handle:Kr({host:t,restored:r})}:r},screenRecordingCleanup:async e=>await vr(t,n,e.envelope.descriptor.body,e.envelope.sessionId)})}async function Wr(e){return e.signal.throwIfAborted(),e.device.kind===`simulator`?await Gr(e):await Jr(e)}async function Gr(e){let{host:t,device:n,owner:r,input:i,signal:a}=e;await zr(n,i,t.screenRecording.apple.isRunnerBundleId);let o=i.activeSessionApp?await t.screenRecording.apple.captureClockAnchor(n,i.activeSessionApp.bundleId,a):void 0,s=kt(i.outputPath);await t.screenRecording.outputs.prepare(s);let c=await t.screenRecording.apple.startSimulator(n,s,a),l=c.markers;if(!l||l.length===0)throw await $r(c).catch(()=>{}),Error(`simctl recordVideo did not expose durable process identity`);try{a.throwIfAborted(),t.screenRecording.ownedProcesses.replace({kind:`session`,sessionId:i.sessionId},l.map(e=>({...e,purpose:`simctl-screen-recording`})))}catch(e){try{t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId})}catch{}throw await $r(c).catch(()=>{}),e}let u,d,f=async()=>{await c.terminate();let e=await c.wait;return d=e,u=Xr(e),t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId}),{observation:{recorder:`confirmed`},...u===void 0?{}:{warning:`${u} before record stop; the video covers only what the recorder wrote before it stopped.`}}},p=ni(i,Vr,{},o);return ti({device:n,owner:r,input:i,descriptor:{backend:`simctl`,outputPath:s,processes:l,recording:_r(p)},snapshot:p,finish:(e,n)=>pt({snapshot:e,progress:n,steps:{stop:f,collect:async e=>{try{await qr(t,s,e)}catch(e){throw Zr(e,u,d)}},finalize:async({collectedPath:n,exportPath:r})=>{try{return await fr({host:t,snapshot:e,targetLabel:Br,collectedPath:n,exportPath:r,nativePath:s})}catch(e){throw Zr(e,u,d)}},discard:async e=>{await t.screenRecording.outputs.remove(e)}}}),cleanup:async()=>{let e=await ei(c);return(e.status===`cleaned`||e.status===`already-missing`)&&t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId}),e}})}function Kr(e){let{host:t,restored:{recording:n,nativePath:r,cleanup:i}}=e,a=Object.freeze({...n,backend:Vr,gestureEvents:[]});return ct(a,{finish:(e,i)=>pt({snapshot:e,progress:i,steps:{stop:async()=>({observation:{recorder:`confirmed`},warning:`simctl recordVideo had already ended when record stop reattached to it; the video covers only what the recorder wrote before it stopped.`}),collect:async e=>{await qr(t,r,e)},finalize:async({collectedPath:i,exportPath:a})=>await fr({host:t,snapshot:e,targetLabel:Br,collectedPath:i,exportPath:a,nativePath:r,...n.showTouches?{overlayUnavailable:`the daemon that held the touch events ended before record stop`}:{}}),discard:async e=>{await t.screenRecording.outputs.remove(e)}}}),forceCleanup:async()=>await i()})}async function qr(e,t,n){await e.screenRecording.outputs.copy({from:t,to:n}),await e.screenRecording.finalize.sniff({outputPath:n})}async function Jr(e){let{host:t,device:n,owner:r,input:i,signal:a}=e,o=i.activeSessionApp?.bundleId;if(!o)throw TypeError(`Apple runner recording requires an active app session identity`);await t.screenRecording.outputs.prepare(i.outputPath);let s=await t.screenRecording.apple.runRunner(n,{kind:`start`,appBundleId:o,outputPath:i.outputPath,...i.fps===void 0?{}:{fps:i.fps}},a);if(!s.runnerSessionId||!s.runnerAuthority)throw Error(`Apple runner recording did not expose durable session ownership`);let c={runnerSessionId:s.runnerSessionId,runnerAuthority:s.runnerAuthority},l,u=()=>(l??=Yr(()=>t.screenRecording.apple.runRunner(n,{kind:`stop`,appBundleId:o,...c}).then(()=>void 0)).catch(e=>{throw l=void 0,e}),l);if(!Qr(n,s.remotePath))throw await u().catch(()=>{}),Error(`Apple runner recording did not expose coherent durable media ownership`);try{a.throwIfAborted()}catch(e){throw await u().catch(()=>{}),e}return ti({device:n,owner:r,input:i,descriptor:{backend:`runner`,outputPath:i.outputPath,appBundleId:o,...c,...s.remotePath===void 0?{}:{remotePath:s.remotePath}},snapshot:ni(i,`runner AVAssetWriter`,s),finish:async e=>(await u(),s.remotePath!==void 0&&await t.screenRecording.apple.retrieveRunnerRecording(n,s.remotePath,e.outPath),await dr({host:t,snapshot:e,targetLabel:n.appleOs===`macos`?`macOS recording`:`iOS recording`,stopObservation:{recorder:`confirmed`},...s.remotePath===void 0?{}:{nativePathDisposition:`retirable`}})),cleanup:async()=>(await u(),{status:`cleaned`})})}async function Yr(t){try{return await t()}catch(t){throw e(t,`COMMAND_FAILED`)}}function Xr(e){if(e.exitCode!==0)return e.signal?`simctl recordVideo was killed by ${e.signal}`:`simctl recordVideo exited with code ${e.exitCode}`}function Zr(t,n,r){let a=e(t,`COMMAND_FAILED`);return n===void 0||r===void 0||a.details?.reason!==`recording-output-unplayable`?t:new i(a.code,`${a.message}; ${n}`,y(r,{...a.details??{},...r.signal===void 0?{}:{signal:r.signal},retriable:!1,hint:`The recorder exited before record stop, so the next record stop reads the same file. Close this session to release the device, then record again.`}))}function Qr(e,t){return e.appleOs===`macos`||!m(e)?t===void 0:t!==void 0&&/^tmp\/agent-device-recording-\d+\.mp4$/.test(t)}async function $r(e){return await e.terminate(),await e.wait}async function ei(e){try{return await $r(e),{status:`cleaned`}}catch(e){return{status:`cleanup-pending`,reason:`transport-failed`,message:e instanceof Error?e.message:`Apple simulator cleanup failed`}}}function ti(e){let{device:t,owner:n,input:r,descriptor:i,snapshot:a,finish:o,cleanup:s}=e,c=ct(a,{finish:o,forceCleanup:s});return Object.freeze({pendingHandle:new Xe(c),envelope:gr({device:t,owner:n,input:r,descriptor:i})})}function ni(e,t,n={},r){let i=Date.now();return Object.freeze({backend:t,outPath:e.outputPath,...e.clientOutputPath===void 0?{}:{clientOutPath:e.clientOutputPath},startedAt:i,scope:e.scope,showTouches:e.showTouches,recordOnlySession:e.recordOnlySession,...e.activeSessionApp===void 0?{}:{activeSessionApp:e.activeSessionApp},...e.exportQuality===void 0?{}:{exportQuality:e.exportQuality},...e.fps===void 0?{}:{fps:e.fps},gestureEvents:[],...r===void 0?{}:{gestureClockOriginAtMs:r.wallClockAtMs,gestureClockOriginUptimeMs:r.uptimeMs},...n.recorderStartUptimeMs===void 0?{}:{gestureClockOriginAtMs:i,gestureClockOriginUptimeMs:n.recorderStartUptimeMs,runnerStartedAtUptimeMs:n.recorderStartUptimeMs},...n.runnerSessionId===void 0?{}:{runnerSessionId:n.runnerSessionId}})}const ri=15e3;async function M(e,t,n,r={}){return n.throwIfAborted(),await jt(t)||p(t)?{...t,booted:!0}:t.kind===`device`?(await e.deviceReadiness.applePhysical.ensureConnected(t,n),{...t,booted:!0}):t.kind===`simulator`?((await ii(e,t)?`Booted`:await ci(e,t,n))!==`Booted`&&(r.onColdBootStart?.(),e.deviceReadiness.appleAutomation.keepHot(t),await ai(e,t,n,r.deadlineAtMs),await li(e,n)),e.deviceReadiness.appleAutomation.keepHot(t),e.deviceReadiness.appleAutomation.markBooted(t),{...t,booted:!0}):{...t,booted:!0}}async function ii(e,t){try{return await e.deviceReadiness.appleAutomation.wasRecentlyObservedBooted(t)}catch{return!1}}async function ai(e,t,n,r=Date.now()+12e4){let i=!1;try{i=await oi(e,t,n,r),await si(e,t,n,r)}catch(a){throw i&&n.aborted&&ui(e,t),n.throwIfAborted(),Date.now()>=r?P(t,a):a}}async function oi(e,t,n,r){let a=await e.appleTools.run({tool:`simctl`,args:b(t,[`boot`,t.id]),allowFailure:!0,timeoutMs:N(r,t)},n),o=`${a.stdout}\n${a.stderr}`.toLowerCase(),s=o.includes(`already booted`)||o.includes(`current state: booted`);if(a.exitCode!==0&&!s)throw new i(`COMMAND_FAILED`,`simctl boot failed`,{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});return!s}async function si(e,t,n,r){me({type:`command`,status:`progress`,message:`Waiting for the Simulator to finish booting...`});let a=await e.appleTools.run({tool:`simctl`,args:b(t,[`bootstatus`,t.id,`-b`]),allowFailure:!0,timeoutMs:N(r,t)},n);if(a.exitCode!==0)throw new i(`COMMAND_FAILED`,`simctl bootstatus failed`,{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});if(await en(e.appleTools,t,n,Math.min(ri,N(r,t)))!==`Booted`)throw new i(`COMMAND_FAILED`,`Simulator is still booting`,{deviceId:t.id});if(Date.now()>=r)throw P(t)}function N(e,t){let n=e-Date.now();if(n<=0)throw P(t);return n}function P(e,t){return new i(`COMMAND_FAILED`,`Simulator did not finish booting within the startup budget`,{reason:_t,deviceId:e.id,hint:`The Simulator keeps booting in the background; a first boot can take several minutes. Retry once it is up, or pass a larger --timeout.`},t instanceof Error?t:void 0)}async function ci(e,t,n){return await en(e.appleTools,t,n,ri)}async function li(e,t){await e.commands.run({executable:`open`,args:[`-a`,`Simulator`],allowFailure:!0,timeoutMs:1e4},t)}function ui(e,t){e.appleTools.run({tool:`simctl`,args:b(t,[`shutdown`,t.id]),allowFailure:!0}).catch(()=>{})}const di=Object.freeze({resolveOpenTarget:`simulator`,prepareApplicationOpen:`simulator`,openApplication:`simulator`,applyRuntimeHints:`simulator`,clearRuntimeHints:`simulator`,closeApplication:`simulator`,finalizeApplicationClose:`simulator`,prepareAppleRunner:`runner`,configureProviderPortReverse:`simulator`,ensureReady:`simulator`,bootTarget:`simulator`,bootTargetHeadless:`simulator`,shutdownTarget:`simulator`,listApps:`simulator`,deployApp:`simulator`,materializeAppSource:`simulator`,deployMaterializedApp:`simulator`,sendPushNotification:`simulator`,appState:`simulator`,appLogStart:`simulator`,appLogInspect:`simulator`,appLogDoctor:`simulator`,appLogReattach:`simulator`,appLogCleanup:`simulator`,networkDump:`simulator`,audioProbeStart:`simulator`,audioProbeQuery:`simulator`,audioProbeReattach:`simulator`,audioProbeCleanup:`simulator`,readClipboard:`simulator`,writeClipboard:`runner`,setSetting:`simulator`,readSetting:`simulator`,setFoldPose:`simulator`,captureSnapshot:`simulator`,captureSnapshotWithoutActiveApp:`simulator`,captureSnapshotWithCustomActions:`runner`,captureScreenshot:`simulator`,findText:`runner`,readTextAtPoint:`runner`,tapPoint:`runner`,tapRef:`runner`,tapElementSelector:`runner`,fillPoint:`runner`,fillRef:`runner`,longPressPoint:`runner`,hoverPoint:`runner`,hoverRef:`runner`,focusPoint:`runner`,typeText:`runner`,scrollDirection:`runner`,performGesturePlan:`runner`,performMultiTouchGesturePlan:`runner`,performTargetAuthoredDrag:`runner`,performDirectionalFlingPlan:`runner`,gestureViewport:`runner`,setViewport:`runner`,back:`runner`,home:`runner`,setOrientation:`runner`,appSwitcher:`runner`,actionButton:`runner`,tvRemote:`runner`,keyboardDismiss:`runner`,keyboardEnter:`runner`,keyboardStatus:`runner`,triggerAppEvent:`runner`,readAlert:`runner`,awaitAlert:`runner`,acceptAlert:`runner`,dismissAlert:`runner`,perfFrames:`runner`,perfMemorySample:`runner`,perfMemorySnapshot:`runner`,perfNativeCaptureStart:`runner`,perfNativeCaptureReattach:`runner`,perfNativeCaptureCleanup:`runner`,perfProfileReport:`runner`,screenRecordingStart:`runner`,screenRecordingReattach:`runner`,screenRecordingCleanup:`runner`});function fi(e){return e===void 0?`possible`:e.some(e=>di[e]===`runner`)?`required`:`none`}const pi=3e3,mi=`simulator-target-discovery-pending`,hi=`simulator-target-unavailable`;function gi(){let e=new Map,t=new Map,n=dn({waitMs:1500});return async(r,i,a,o)=>{a.throwIfAborted();let s=`${r.id}:${i}`,c=e.get(s);if(c&&o!==`refresh`){let e=await on(c.pid,{signal:a,timeoutMs:pi});if(a.throwIfAborted(),e===c.processStartTime)return c}return e.delete(s),await n.value(s,{start:async()=>{let n=await bi(r,i,t);return e.set(s,n),n},wait:(e,t)=>rn({waitMs:e,signal:a,stop:t,cancelled:()=>_i(a)}),pending:()=>I(mi,r,i)})}}function _i(e){return t({readinessPhase:`target-discovery`},e.reason)}function vi(e){return e instanceof i&&e.details?.reason===mi}function yi(e){return e instanceof i&&e.details?.reason===hi}async function bi(e,t,n){let r=Date.now()+15e3,[i,a]=await Promise.allSettled([qt(e,[`spawn`,e.id,`launchctl`,`list`],{allowFailure:!0,timeoutMs:F(r)}),xi(e,n,r)]);if(i.status===`rejected`)throw i.reason;if(a.status===`rejected`)throw a.reason;let o=i.value,s=a.value;if(o.exitCode!==0)throw I(`simulator-target-probe-failed`,e,t);let c=Si(o.stdout,t);if(!c)throw I(hi,e,t);let l=await on(c.pid,{timeoutMs:Math.min(pi,F(r))});if(!l)throw I(`simulator-target-identity-unavailable`,e,t);return Object.freeze({simulator:Jt(e),runtime:s,pid:c.pid,generation:`${c.pid}:${c.label}:${l}`,targetId:`${e.id}:${t}`,processStartTime:l})}async function xi(e,t,n){let r=t.get(e.id);if(r)return await r;let i=qt(e,[`list`,`devices`,`-j`],{allowFailure:!0,timeoutMs:F(n)}).then(t=>{if(t.exitCode!==0)throw I(`simulator-runtime-probe-failed`,e,``);let n=Object.entries(Wt(t.stdout)).find(([,t])=>t.some(t=>t.udid===e.id))?.[0];if(!n)throw I(`simulator-runtime-unavailable`,e,``);return n});t.set(e.id,i);try{return await i}catch(n){throw t.delete(e.id),n}}function Si(e,t){for(let n of e.split(`
|
|
4
|
+
`)){let[e,,r]=n.trim().split(/\s+/);if(!e||!r||!r.startsWith(`UIKitApplication:${t}[`))continue;let i=Number(e);if(Number.isSafeInteger(i)&&i>0)return{pid:i,label:r}}}function F(e){return Math.max(1,e-Date.now())}function I(e,t,n){return new i(`COMMAND_FAILED`,`Unable to resolve the running iOS Simulator app (${e}).`,{reason:e,deviceId:t.id,appBundleId:n})}function Ci(e){return e?.observation===`unobservable`&&e.proof===`no-running-process`}const wi=new Map([[`application-element-missing`,5e3],[`application-server-unavailable`,5e3],[`foreground-owner-unverified`,1e3],[`foreground-owner-changed`,1e3]]);function L(e){return e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`}function Ti(e){let t=de(pe({depth:1,interactiveOnly:!0}));return Object.freeze({awaitObservable:async(n,r,i)=>{if(!L(n))return{observation:`not-eligible`};let a;for(;;){let o=await Di(e.resolveTarget,n,r,i);if(`verdict`in o)return o.verdict;let{target:s}=o;if(e.isBridgeDisabled(s))return l({level:`debug`,phase:`ios_launch_observation_skipped`,data:{reason:`circuit-disabled`,deviceId:n.id,generation:s.generation}}),Ei({source:`circuit`});let c=await e.source.acquire({target:s,hint:t,signal:i});if(c.stage!==`failed`)return{observation:`observable`};i.throwIfAborted();let{kind:u,code:d}=c.failure,f=wi.get(d);if(f===void 0)return Ei({source:`bridge`,kind:u,code:d});let p=e.clock.now();if(a=Math.min(a??1/0,p+f),p>=a)return{observation:`unobservable`,proof:`launch-transition`};await e.clock.sleep(Math.min(150,a-p),i)}}})}function Ei(e){return{observation:`probe-failed`,failure:e}}async function Di(e,t,r,i){for(;;)try{return{target:await e(t,r,i)}}catch(e){if(i.throwIfAborted(),vi(e))continue;if(yi(e))return{verdict:{observation:`unobservable`,proof:`no-running-process`}};let{code:t,details:r}=n(e),a=r?.reason;return{verdict:Ei(typeof a==`string`?{source:`target`,code:t,reason:a}:{source:`target`,code:t})}}}function Oi(e,t,n){let r=n&&L(e),i=r?fi(t.execution.plannedOperations):void 0,a=m(e)&&t.surface===`app`&&t.positionals.length>0&&!!t.appBundleId&&i!==`none`;return{...i?{runnerDemand:i}:{},shouldPrewarmRunner:a,awaitPrewarmAfterOpen:t.relaunch&&!r}}function ki(e,t,n,r){r.runnerDemand===`none`&&e.appleApplications.releaseSpeculativeRunner(t.device,n.execution).catch(()=>{})}async function Ai(e,t,n,r,a,o){let s=Date.now(),c=async()=>await Fi(t,n,r,a.observation),l=await c(),u,d=a.answerConfirmation,f=d&&l?.observation!==`observable`?await ji(d,a.redispatchLaunchUrl,c,l):void 0;if(f&&(o.runnerDemand=`required`,u=f.launchConfirmation,l=f.observed,f.unanswered))throw new i(`COMMAND_FAILED`,`The Simulator has not completed the launch URL for ${n.appBundleId}.`,{reason:`launch_confirmation_unanswered`,appBundleId:n.appBundleId,hint:`iOS may still be holding an "Open in" prompt, or the answer died with the runner session that raised it. Inspect the current alert before deciding on another action.`});return r&&l?.observation!==`observable`&&await e.clock.sleep(300,t.signal),l&&(o.postOpenObservation=l.observation,l.observation===`probe-failed`&&(o.postOpenObservationFailure=l.failure)),o.postOpenSettleDurationMs=Math.max(0,Date.now()-s),u}async function ji(e,t,n,r){let i={observed:r,acceptAttempted:!1,confirmationStillPresent:!1};for(let r=0;r<2;r+=1){i=await Mi(e,n,i);let a=r===1;if(i.confirmationStillPresent||a||!Ni(i)||!t)break;await t()}return{observed:i.observed,launchConfirmation:i.launchConfirmation,unanswered:Ni(i)||i.confirmationStillPresent}}async function Mi(e,t,n){let r=await e(),i=r.outcome===`unanswered`&&r.reason===`alert-still-present`,a=n.acceptAttempted||Pi(r),o=r.outcome===`accepted`?`accepted`:n.launchConfirmation;return a?{observed:await t(),launchConfirmation:o,acceptAttempted:a,confirmationStillPresent:i}:{observed:n.observed,launchConfirmation:o,acceptAttempted:a,confirmationStillPresent:i}}function Ni(e){return e.acceptAttempted&&Ci(e.observed)}function Pi(e){return e.outcome===`accepted`||e.outcome===`unanswered`&&e.reason===`alert-still-present`||e.outcome===`unreadable`&&e.step===`alert-accept`}async function Fi(e,t,n,r){if(!(!n||!L(e.device))&&!(!r||!t.appBundleId))return await r.awaitObservable(e.device,t.appBundleId,e.signal)}let Ii;const Li=()=>Ii??=import(`./launch-confirmation.js`);function Ri(e){let t=Mt({device:e.device,signal:e.signal,resolveInteractor:e.host.localInteractors.resolve});return Object.freeze({resolveOpenTarget:async t=>await e.host.appleApplications.resolveOpenTarget(e.device,t),prepareApplicationOpen:async t=>{await M(e.host,e.device,e.signal,{deadlineAtMs:t.execution.startupDeadlineAtMs,onColdBootStart:t.prewarmRunnerOnColdBoot?()=>{e.host.appleApplications.prewarmRunnerCache(e.device,t.execution,e.signal).catch(()=>{})}:void 0})},openApplication:async n=>await zi(e.host,t,n,e.observation),applyRuntimeHints:async t=>await e.host.appleApplications.applyRuntimeHints(e.device,t),clearRuntimeHints:async t=>await e.host.appleApplications.clearRuntimeHints(e.device,t),closeApplication:async n=>await Qi(e.host,t,n),finalizeApplicationClose:async t=>await $i(e.host,e.device,e.signal,t),prepareAppleRunner:async t=>await ea(e.host,e.device,e.signal,t),configureProviderPortReverse:oa})}async function zi(e,t,n,r){let i={},a=R(t.device),o=ra(t.device,n,a),s=ta(e,t,n,i),c=Oi(t.device,n,a);c.runnerDemand&&(i.runnerDemand=c.runnerDemand),ki(e,t,n,c);let{shouldPrewarmRunner:l}=c,u=Zi(t.device,n,a);a&&l&&!n.prewarmRunnerBeforeOpen&&s.schedule();try{await Bi(e,t,n,a,u,i),await Vi(n,i),await Hi(s,l,n.prewarmRunnerBeforeOpen);let d=s.wasAwaited();await Ui(t,n,o,a,i),await Ji(s,l,c.awaitPrewarmAfterOpen),await Yi(e,t,n,a,d,u);let f=await Ai(e,t,n,a,{observation:r,answerConfirmation:Ki(t,n,o),redispatchLaunchUrl:qi(t,n,o)},i);return{appBundleId:n.appBundleId,timing:i,...f?{launchConfirmation:f}:{}}}catch(n){throw u&&await e.appleApplications.stopRunnerSession(t.device.id).catch(()=>{}),n}}async function Bi(e,t,n,r,i,a){if(!Xi(n,r)||!n.target)return;let o=Date.now();f(t.device.platform)&&!r&&!i&&await e.appleApplications.stopRunnerSession(t.device.id),await Nt({device:t.device,interactor:await t.resolveInteractor(n.execution,n.appBundleId),positionals:[n.appBundleId??n.target]}),r&&await e.clock.sleep(300,t.signal),a.relaunchCloseDurationMs=z(o)}async function Vi(e,t){if(!ge(e.runtimeHints))return;if(!e.applyRuntimeHints)throw new i(`COMMAND_FAILED`,`Runtime hint operation was not admitted for this open.`,{reason:`runtime-hints-operation-missing`});let n=Date.now();await e.applyRuntimeHints({appId:e.appBundleId,values:e.runtimeHints}),t.runtimeHintsDurationMs=z(n)}async function Hi(e,t,n){!t||!n||(e.schedule(!0),await e.wait())}async function Ui(e,t,n,r,i){let a=Date.now();await Pt({device:e.device,interactor:await e.resolveInteractor(t.execution,t.appBundleId),positionals:n.positionals,appBundleId:t.appBundleId,execution:t.execution,...r&&t.relaunch&&!t.execution.clearAppState?{terminateRunningApp:!0}:{}}),i.openDispatchDurationMs=z(a),await Wi(e,t,n.followUpUrl,i)}async function Wi(e,t,n,r){if(!n){r.launchUrlDurationMs=0;return}let i=Date.now();await Gi(e,t,n),r.launchUrlDurationMs=z(i)}async function Gi(e,t,n){let r={...t.execution,clearAppState:void 0,launchConsole:void 0,launchArgs:void 0};await Pt({device:e.device,interactor:await e.resolveInteractor(r,t.appBundleId),positionals:[n],appBundleId:t.appBundleId,execution:r})}function Ki(e,t,{confirmation:n}){if(n)return async()=>{let{answerSimulatorLaunchConfirmation:r}=await Li();return await r(e.device,n,e.resolveInteractor(t.execution,n.appBundleId),e.signal)}}function qi(e,t,{confirmation:n}){if(n)return async()=>{await Gi(e,t,n.url)}}async function Ji(e,t,n){t&&!e.wasScheduled()&&e.schedule(),n?await e.wait():e.recordUnawaited()}async function Yi(e,t,n,r,i,a){!m(t.device)||!r&&!a||!n.relaunch&&!i||r&&!i&&!await e.appleApplications.hasLiveRunnerSession(t.device,n.execution)||await e.appleApplications.notifyRunnerAppRelaunched(t.device,n.execution,t.signal)}function Xi(e,t){return!!(e.relaunch&&e.target)&&!(t&&!e.execution.clearAppState)}function Zi(e,t,n){return e.kind===`device`&&e.appleOs===`ios`&&Xi(t,n)}async function Qi(e,t,n){n.ensureReady&&await M(e,t.device,t.signal),f(t.device.platform)&&!R(t.device)&&await e.appleApplications.stopRunnerSession(t.device.id),await Nt({device:t.device,interactor:await t.resolveInteractor(n.execution,n.appBundleId),positionals:n.positionals}),R(t.device)&&await e.clock.sleep(300,t.signal)}async function $i(e,t,n,r){r.daemonShutdown||await e.appleApplications.releaseRunnerOnClose(t.id,{retain:r.retainRunner}),await e.appleApplications.dismissCloseAlerts(t,r).catch(()=>{});let i=r.shutdownTarget&&R(t)?await e.deviceShutdown.apple.shutdownTarget(t,n):void 0;return i===void 0?{}:{shutdown:i}}async function ea(e,t,n,r){let i=Date.now()+r.timeoutMs;await M(e,t,n,{deadlineAtMs:i});let a=Math.max(1,i-Date.now());return await e.appleApplications.prepareRunner(t,{...r,timeoutMs:a},n)}function ta(e,t,n,r){let i,a=!1,o=na(t.device,n)?{healthCheck:!1}:void 0;return{schedule:(a=!1)=>{i||=(r.runnerPrewarmKind=`session`,r.runnerPrewarmScheduled=!0,o?e.appleApplications.prewarmRunnerSession(t.device,n.execution,t.signal,a,o):e.appleApplications.prewarmRunnerSession(t.device,n.execution,t.signal,a))},wait:async()=>{if(!i||a)return;a=!0;let e=Date.now();await i,r.runnerPrewarmWaited=!0,r.runnerPrewarmDurationMs=z(e)},wasAwaited:()=>a,wasScheduled:()=>i!==void 0,recordUnawaited:()=>{i&&!a&&(r.runnerPrewarmWaited=!1)}}}function na(e,t){return e.kind===`device`&&e.appleOs===`ios`&&!t.hasExistingSession&&!t.relaunch&&!t.prewarmRunnerBeforeOpen}function ra(e,t,n){let r=t.runtimeLaunchUrl?.trim(),i=t.positionals.length===1?t.positionals[0]?.trim():void 0;if(!r||!i||o(i))return{positionals:t.positionals};let a=ia(e,t.appBundleId,r),s=a?{confirmation:a}:{};return n&&!aa(t)?{positionals:[i,r],...s}:{positionals:t.positionals,followUpUrl:r,...s}}function ia(e,t,n){if(e.appleOs===`ios`&&e.kind===`simulator`&&!(t===void 0||a(n)))return{url:n,appBundleId:t}}function aa(e){return e.execution.clearAppState===!0||!!e.execution.launchConsole?.trim()||!!e.execution.launchArgs?.length}function R(e){return m(e)&&e.kind===`simulator`}function z(e){return Math.max(0,Date.now()-e)}async function oa(){throw new i(`UNSUPPORTED_OPERATION`,`This lifecycle operation is unavailable for Apple.`)}const sa=Object.freeze({available:!0}),ca=Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`}),la=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`Push notifications are supported on Apple simulators only.`}),ua=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),da=Object.freeze({available:!1,reason:`unsupported-device-kind`});function fa(e){let t=ba(e);return Object.freeze({deployApp:t,materializeAppSource:t,deployMaterializedApp:t,sendPushNotification:xa(e)})}function pa(e){let{host:t,device:n,signal:r}=e,i=fa(n);return Object.freeze({...i.deployApp.available?{deployApp:async e=>await ma(t,n,e,r),materializeAppSource:async e=>await t.appleDeployment.prepareArtifact(e,{signal:r}),deployMaterializedApp:async e=>await ha(t,n,e,r)}:{},...i.sendPushNotification.available?{sendPushNotification:async e=>(await va(t,n,e,r),{})}:{}})}async function ma(e,t,n,r){if(n.replaceExisting)return await e.appleDeployment.withInvalidatedAppResolutionCache(t,async()=>{let i=await e.appleDeployment.resolveAppBundleId(t,n.app);await _a(e,t,i,r);let a=await e.appleDeployment.prepareArtifact({source:{kind:`path`,path:n.appPath}},{appIdentifierHint:n.app,signal:r});try{return await ga(e,t,a.installablePath,r),{bundleId:i,launchTarget:i}}finally{await a.cleanup()}});let i=await e.appleDeployment.prepareArtifact({source:{kind:`path`,path:n.appPath}},{appIdentifierHint:n.app,signal:r});try{return await ha(e,t,{artifact:i},r)}finally{await i.cleanup()}}async function ha(e,t,n,r){return await ga(e,t,n.artifact.installablePath,r),{...n.artifact.bundleId?{bundleId:n.artifact.bundleId}:{},...n.artifact.appName?{appName:n.artifact.appName}:{},...n.artifact.bundleId?{launchTarget:n.artifact.bundleId}:{}}}async function ga(e,t,n,r){await M(e,t,r),await ya(e,t.kind===`simulator`?{tool:`simctl`,args:b(t,[`install`,t.id,n])}:{tool:`devicectl`,args:[`device`,`install`,`app`,`--device`,t.id,n],timeoutMs:It},r,`Apple app install failed`)}async function _a(e,t,n,r){await M(e,t,r),await ya(e,t.kind===`simulator`?{tool:`simctl`,args:b(t,[`uninstall`,t.id,n])}:{tool:`devicectl`,args:[`device`,`uninstall`,`app`,`--device`,t.id,n]},r,`Apple app uninstall failed for ${n}`,{tolerate:e=>Ht(`${e.stdout}\n${e.stderr}`.toLowerCase())})}async function va(e,t,n,r){if(t.kind!==`simulator`)throw new i(`UNSUPPORTED_OPERATION`,`Apple push notifications require a simulator`);await M(e,t,r);let a=await e.temporaryFiles.create({prefix:`agent-device-ios-push-`,suffix:`.apns`});try{await a.writeText(`${JSON.stringify(n.payload)}\n`),await ya(e,{tool:`simctl`,args:b(t,[`push`,t.id,n.appId,a.path])},r,`Apple push notification failed`)}finally{await a[Symbol.asyncDispose]()}}async function ya(e,t,n,r,i){let a=await e.appleTools.run({...t,allowFailure:!0},n);return i?.tolerate?.(a)?a:ce(a,r,e=>({cmd:`xcrun`,args:[t.tool,...t.args],...t.tool===`devicectl`?{hint:Vt(e.stdout,e.stderr)??`Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.`}:{}}))}function ba(e){return Sa(e)?e.kind!==`simulator`&&e.kind!==`device`?da:e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?ca:sa:ua}function xa(e){return Sa(e)?e.kind===`simulator`?sa:la:ua}function Sa(e){return m(e)&&e.appleOs!==`watchos`}const B=Object.freeze({available:!0}),Ca=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`back is supported on Apple simulators and physical devices.`}),wa=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function Ta(e){return e.kind!==`simulator`&&e.kind!==`device`?Ca:u(e)===`watchos`?wa:B}const Ea=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`home is supported on Apple simulators and physical devices.`}),Da=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),Oa=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`app-switcher is supported on Apple simulators and physical devices.`});function ka(e,t){if(e.kind!==`simulator`&&e.kind!==`device`)return t;let n=u(e);return n===`macos`||n===`watchos`?Da:B}function V(e){if(e.kind!==`simulator`&&e.kind!==`device`)return!1;let t=u(e);return t!==`tvos`&&t!==`macos`&&t!==`watchos`}const Aa=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`orientation is supported on Apple simulators and physical devices.`}),ja=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function Ma(e){return e.kind!==`simulator`&&e.kind!==`device`?Aa:V(e)?B:ja}const Na=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`tv-remote is supported only on tvOS devices.`});function Pa(e){return(e.kind===`simulator`||e.kind===`device`)&&te(e)?B:Na}const H=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),Fa=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`keyboard status/get is currently supported only on Android; use keyboard dismiss or enter on iOS`});function Ia(e){return V(e)?Fa:H}function La(e){return V(e)?B:H}function Ra(e){return V(e)?B:H}const za=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`No Apple leaf carries this system button.`}),Ba=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`action-button is supported on iPhone and iPad simulators and physical devices.`}),Va=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`The Action Button is iPhone and iPad hardware; tvOS, macOS, watchOS and visionOS have no such control.`});function Ha(e){return e.kind!==`simulator`&&e.kind!==`device`?Ba:h(e)?B:Va}function Ua(e){return Object.freeze({...Ve({back:Ta(e)}),...Pe({unsupported:za,home:ka(e,Ea),appSwitcher:ka(e,Oa),actionButton:Ha(e)}),...be({orientation:Ma(e)}),...He({tvRemote:Pa(e)}),...Be({unsupported:H,status:Ia(e),dismiss:La(e),enter:Ra(e)})})}function Wa(e){let{host:t,device:n,signal:r,admitted:i}=e,a=Object.keys(Ua(n));return St({device:n,signal:r,resolveInteractor:t.localInteractors.resolve,facts:Object.fromEntries(a.map(e=>[e,i[e]]))})}const U=Object.freeze({available:!0}),Ga=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`clipboard is supported on Apple simulators and the macOS host.`}),Ka=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`settings is supported on Apple simulators and the macOS host.`}),qa=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`settings is supported on Apple simulators and the macOS host, not on physical devices of this OS.`}),Ja=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:"Apple targets answer a settings read only on iPhone and iPad simulators, where `simctl ui` reports the value the device holds."}),Ya=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`clipboard is supported on Apple simulators and the macOS host, not on physical devices of this OS.`}),W=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function Xa(e,t,n){if(e.kind!==`simulator`&&e.kind!==`device`)return t;let r=u(e);return r===`watchos`?W:e.kind===`simulator`||r===`macos`?U:n}function Za(e){return Xa(e,Ga,Ya)}const Qa=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`trigger-app-event is supported on Apple simulators and physical devices.`}),$a=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`alert is supported on Apple simulators and physical devices.`}),eo=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`alert is supported on Apple simulators, the macOS host, and physical iOS devices.`});function to(e){if(e.kind!==`simulator`&&e.kind!==`device`)return $a;let t=u(e);return t===`watchos`?W:e.kind===`simulator`||t===`ios`||t===`macos`?U:eo}function no(e){return e.kind!==`simulator`&&e.kind!==`device`?Qa:u(e)===`watchos`?W:U}function ro(e){let t=Za(e);return t.available?Ya:t}function io(e){return e.kind!==`simulator`&&e.kind!==`device`?Ka:u(e)===`watchos`?W:ee(e)?U:Ja}function ao(e){let t=Za(e),n=to(e);return Object.freeze({...Fe({unsupported:ro(e),read:t,write:t}),...Le({read:n,wait:n,accept:n,dismiss:n}),...ze({triggerAppEvent:no(e)}),...Re({setSetting:Xa(e,Ka,qa),readSetting:io(e)})})}function oo(e){let{host:t,device:n,signal:r}=e;return St({device:n,signal:r,resolveInteractor:t.localInteractors.resolve,facts:ao(n)})}function so(e){return Object.freeze({setFoldPose:e.fold})}const co=/Angle:\s*(-?\d+(?:[.,]\d+)?)\s*°/g;async function lo(e,t={}){let n=[`devicectl`,`device`,`motion`,`hinge-angle`,`--device`,e.id,`--session-timeout`,`1`,`--timeout`,`5`],r=await Bt(n,{allowFailure:!0,signal:t.signal,timeoutMs:Rt}),a=uo(r.stdout)??uo(r.stderr);if(a!==void 0)return a;throw new i(`COMMAND_FAILED`,`CoreDevice reported no hinge angle sample`,y(r,{cmd:`xcrun`,args:n,stdout:r.stdout,stderr:r.stderr,deviceId:e.id,hint:`This Xcode/CoreDevice toolchain does not stream 'devicectl device motion hinge-angle' for this device. Foldable poses can be verified only through that stream; update Xcode to a version that ships it.`}))}function uo(e){let t;for(let n of e.matchAll(co)){let e=Number.parseFloat(n[1].replace(`,`,`.`));Number.isFinite(e)&&(t=e)}return t}const fo=`Fold.m`,po=3e4,mo=Ut+po;async function ho(e={}){let t=e.host??go(),n=cn(mo,e.signal);try{let r=e.sourceRoot??x.join(le(),`apple`,`fold-helper`),i=await ln(t,r,[fo],n),a=await an(t,n),o=e.cacheRoot??x.join(Ft(),`.agent-device`,`fold-helper`);return await un({host:t,deadline:n,lockDescription:`iOS Simulator fold helper cache`,cacheRoot:o,binaryFilename:`fold-helper`,keyInputs:{schemaVersion:1,sourceHash:i,toolchain:a,compileArgv:_o({sourceRoot:``,outputPath:``})},build:e=>vo(t,n,r,e)})}catch(e){throw yo(e)}}function go(){return tn(zt)}function _o(e){return[`--sdk`,`iphonesimulator`,`clang`,`-mios-simulator-version-min=15.0`,`-fobjc-arc`,`-Wall`,`-Wextra`,`-framework`,`Foundation`,`-framework`,`IOKit`,x.join(e.sourceRoot,fo),`-o`,e.outputPath]}async function vo(e,t,n,r){let i=await sn({host:e,deadline:t,argv:_o({sourceRoot:n,outputPath:r}),budgetMs:po,label:`fold helper`});if(i.exitCode!==0||!e.exists(r))throw bo(y(i))}function yo(e){return!(e instanceof nn)||e.buildFailureKind===`cancelled`?e:bo({...e.buildDetails,cause:e.buildFailureCode},e)}function bo(e,t){return new i(`COMMAND_FAILED`,`Unable to build the simulator fold helper`,{hint:`Select an Xcode with the iOS simulator SDK and foldable HID support using DEVELOPER_DIR.`,...e,reason:`fold-helper-build-failed`},t)}async function xo(e,t,n){n?.throwIfAborted();let r=await ho({signal:n});n?.throwIfAborted();let a=typeof t==`string`?0:t.at(-1).atMs,o=typeof t==`string`?t:JSON.stringify(t),s=await qt(e,[`spawn`,e.id,r.path,o],{signal:n,timeoutMs:a+1e4,kill:{signal:`SIGTERM`,graceMs:1e3},allowFailure:!0});if(s.exitCode!==0)throw new i(`COMMAND_FAILED`,`Unable to send the simulator hinge pose`,y(s,{reason:`fold-hid-dispatch-failed`,deviceId:e.id}))}async function So(e,t,n={}){n.signal?.throwIfAborted(),Xt(e,`fold`);let r=t,i=r.keyframes?.at(-1)?.angle,a=r.pose??v(i);Co(e,await Zt(e,{signal:n.signal})),await xo(e,r.keyframes??a,n.signal),l({level:`info`,phase:`apple_fold_pose_dispatched`,data:{deviceId:e.id,pose:a}});let o=await wo(e,a,n.signal,i),s=await No(e,n.signal);return{pose:v(o),hingeAngleDegrees:o,...s?{screen:Po(s)}:{}}}function Co(e,t){if(t.unresolved)throw new i(`COMMAND_FAILED`,`CoreDevice reported no display table for this simulator`,{deviceId:e.id,hint:`fold needs 'devicectl device info displays' to tell a foldable from a single-panel simulator; update Xcode to a version that ships the display-information feature.`});if(!t.multiScreen)throw new i(`UNSUPPORTED_OPERATION`,`${e.name} is not a foldable simulator: fold requires more than one integrated panel`,{deviceId:e.id,reason:`single-panel-device`,hint:`fold sets the hinge angle of a foldable simulator such as iPhone Duo; this simulator reports one integrated panel, so it has no hinge to pose.`})}async function wo(e,t,n,r){let i,a;for(let o=1;o<=4;o+=1)if(n?.throwIfAborted(),a=i,i=await lo(e,{signal:n}),To(i,a,t,r))return i;throw Oo(e,t,i,a,r)}function To(e,t,n,r){return r===void 0?v(e)===n?n!==`half-open`||t!==void 0&&ko(e,t):!1:Eo(e,t,r)}function Eo(e,t,n){return Do(e,n)?n===0||n===180||t!==void 0&&Do(t,n)&&Math.abs(e-t)<=.5:!1}function Do(e,t){return t===void 0||e!==void 0&&Math.abs(e-t)<=.5}function Oo(e,t,n,r,a){return Do(n,a)?a!==void 0&&n!==void 0?Mo(e,v(n),n,r):n!==void 0&&t===`half-open`&&v(n)===t?Mo(e,t,n,r):jo(e,t,n):new i(`COMMAND_FAILED`,`The hinge did not reach the final keyframe angle`,{reason:`fold-angle-unverified`,targetAngleDegrees:a,hingeAngleDegrees:n,deviceId:e.id})}function ko(e,t){return v(e)===`half-open`&&v(t)===`half-open`&&Math.abs(e-t)<=.5}function Ao(e,t,n){return{deviceId:e.id,requestedPose:t,observedPose:n===void 0?void 0:v(n),hingeAngleDegrees:n}}function jo(e,t,n){return new i(`COMMAND_FAILED`,`${e.name} did not reach the ${t} pose: CoreDevice still reports a hinge angle of ${n}°`,{...Ao(e,t,n),reason:`fold-pose-unverified`,hint:`The simulator HID command completed, but the hinge did not follow. Verify that the selected Xcode and simulator runtime support foldable HID control, then retry.`})}function Mo(e,t,n,r){return new i(`COMMAND_FAILED`,`${e.name} was observed ${t} at ${n}° but did not settle: 4 hinge reads never held two consecutive angles within ${Lt}° of each other`,{...Ao(e,t,n),reason:`fold-pose-unsettled`,...r===void 0?{}:{previousHingeAngleDegrees:r},hint:`The hinge reached the requested pose and was still moving when the read budget ended. Retry the fold, then read the angle directly with xcrun devicectl device motion hinge-angle --device <udid> --session-timeout 1 --timeout 5 to see whether the simulator holds the pose.`})}async function No(e,t){let n=await Zt(e,{signal:t});if(!(n.unresolved||n.ambiguous))return n.activeDisplay}function Po(e){return{display:e.name,coordinateSpace:se,widthPt:Math.round(e.widthPx/e.pointScale),heightPt:Math.round(e.heightPx/e.pointScale)}}const Fo=Object.freeze({available:!0}),Io=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`fold is supported on foldable iPhone simulators controlled through simulator HID; a physical device is folded by hand.`}),Lo=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`fold poses the hinge of a foldable iPhone; tvOS, macOS, watchOS and visionOS simulators have no hinge.`});function Ro(e){return{available:!1,reason:`unsupported-device-scope`,hint:`fold cannot resolve a simulator scoped to the set at "${e}": CoreDevice's display inventory and hinge-angle readback need a simulator in the default set, so the pose could not be verified. Run fold without --ios-simulator-device-set.`}}function zo(e){if(e.kind!==`simulator`)return Io;let t=u(e);return t!==`ios`&&t!==`ipados`?Lo:e.simulatorSetPath?Ro(e.simulatorSetPath):Fo}function Bo(e){return so({fold:zo(e)})}function Vo(e){let{device:t,signal:n}=e;return _(Bo(t).setFoldPose,()=>({setFoldPose:async e=>(n.throwIfAborted(),await So(t,e,{signal:n}))}))}function Ho(e,t,n){let r=we({device:t.device,signal:t.signal,resolveInteractor:e.localInteractors.resolve}),i=async i=>{if(i.options?.observeOnly===!0)return await r.captureSnapshot(i);let a=p(t.device)?ae(i.options?.surface,t.appBackend):void 0;if(a)return await e.snapshot.captureSurface(t.device,{...i.options,surface:a},Ne(t.signal,i));if(!n)return await r.captureSnapshot(i);let o=Ne(t.signal,i);return await n.capture(t.device,i,o,async e=>await r.captureSnapshot(e))};return Object.freeze({captureSnapshot:i,captureSnapshotWithCustomActions:i,captureSnapshotWithoutActiveApp:i})}function Uo(e,t){return Object.freeze({findText:async n=>{let r=await Wo(e,t,n);if(!r)return{found:!1};let i=await e.localInteractors.resolve(t.device,{...n.execution,...r});return i.findText?await i.findText(n.text,r):{found:!1}}})}async function Wo(e,t,n){let r=n.options?.appBundleId;if(r===void 0||p(t.device)&&oe(n.options?.surface,t.appBackend)===`macos-helper`)return;let i=n.signal?AbortSignal.any([t.signal,n.signal]):t.signal;if(i.throwIfAborted(),await Go(e,t.device,n.execution))return{appBundleId:r,signal:i}}async function Go(e,t,n){return!L(t)||await e.appleApplications.hasLiveRunnerSession(t,n??{})}const G=Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`The native macOS app backend never starts the XCTest runner, which this command needs. Unset AGENT_DEVICE_MACOS_APP_BACKEND to use XCTest.`});function Ko(e,t){return!p(e)||t!==`native`?{}:Object.freeze({screenRecordingStart:G,screenRecordingReattach:G,prepareAppleRunner:G,longPressPoint:G,...Ve({back:G}),...Te({unsupported:G})})}function qo(){let e,t=!1,n=async()=>(e??=import(`./adapter.js`).then(({createSimulatorSnapshotSource:e})=>e()),await e);return{acquire:async e=>t?{stage:`failed`,failure:{kind:`unsupported`,code:`source-closed`}}:await(await n()).acquire(e),close:async()=>{t=!0,e&&await(await e).close()}}}function Jo(e=Date.now){let t=new Map;return async(n,r)=>{if(n.kind!==`simulator`)return`absent`;let i=t.get(n.id);if(i!==void 0&&e()-i.at<1e3)return{kind:`present`,host:i.host};t.delete(n.id);let a=await Yo(n,r);return a!==`absent`&&a!==`unknown`&&t.set(n.id,{at:e(),host:a.host}),a}}async function Yo(e,t){let n=!1;for(let r of yt){let i=await Xo(r.processExecutable,t);if(i===`unknown`){n=!0;continue}for(let a of i){let i=await Zo(a,e.id,t);if(i===`unknown`)n=!0;else if(i)return{kind:`present`,host:r}}}return n?`unknown`:`absent`}async function Xo(e,t){let n=await Qo(`pgrep`,[`-f`,e],t);return n===`unknown`?`unknown`:n.exitCode===1?[]:n.exitCode===0?n.stdout.split(`
|
|
5
|
+
`).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isSafeInteger(e)&&e>0):`unknown`}async function Zo(e,t,n){let r=await Qo(`ps`,[`eww`,`-p`,String(e),`-o`,`command=`],n);return r===`unknown`||r.exitCode!==0?`unknown`:r.stdout.includes(`SIMULATOR_UDID=${t}`)?!0:!r.stdout.includes(`SIMULATOR_UDID=`)&&`unknown`}async function Qo(e,t,n){try{let r=await zt(e,t,{allowFailure:!0,timeoutMs:3e3,...n?{signal:n}:{}});return{exitCode:r.exitCode,stdout:r.stdout}}catch{return`unknown`}}const $o=`system-surface-presented`,es=`system-surface-host-lingering`,ts=`window-coordinate-space-unresolved`;function ns(e,t={}){let n=t.source??qo(),r=t.resolveTarget??gi(),a=t.systemSurfacePresent??Jo(),o=new Set,s=new Map,l=e=>(_s(e,s,o),o.has(vs(e))),u=Ti({source:n,resolveTarget:r,clock:e.clock,isBridgeDisabled:l});return Object.freeze({awaitObservable:u.awaitObservable,shutdown:async()=>await n.close(),capture:async(t,s,u,d)=>{if(!as(t,s))return await ls(t,s,d);let f=await a(t,u);if(f===`unknown`)return await K(t.id,s,d,ds(t.id,s),q(s),`system-surface-probe-unavailable`,[gs()]);if(f!==`absent`)return await cs(t,s,d,f.host.bundleId);let p;try{p=await rs(e,r,t,s,u)}catch(e){return is(u,e),J(`target-resolution-failed`,t,void 0,e),await K(t.id,s,d,ds(t.id,s),q(s),`target-resolution-failed`,[gs()])}if(l(p))return J(`circuit-disabled`,t,p.generation),await K(t.id,s,d,p,q(s),`circuit-disabled`);let m=q(s),h=await n.acquire({target:p,hint:de(m),signal:u});if(h.stage===`failed`){if(h.failure.kind===`cancelled`)throw u.throwIfAborted(),new i(`COMMAND_FAILED`,`Simulator AX snapshot acquisition was cancelled.`,{reason:h.failure.code,...h.failure.details});let e=await hs(h.failure,p,t,s.options.appBundleId,u,r);return await os(s,d,p,e,m,h.failure,o)}try{return await c(`ios.snapshot-source.present`,async()=>await e.snapshot.presentIosAcquisition(h,s.options),{producer:`simulator-ax-bridge`})}catch(e){return await os(s,d,p,{lineage:p,residue:[]},m,{kind:`malformed-tree`,code:`presentation-invariant`},o,e)}}})}async function rs(e,t,n,r,i){let a=r.options.appBundleId;for(;;)try{return await t(n,a,i)}catch(t){if(!vi(t))throw t;let i={requestId:r.execution?.requestId};if(await e.appleApplications.hasLiveRunnerSession(n,i))throw t}}function is(e,t){if(e.aborted)throw r(t)?t:e.reason}function as(e,t){return e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`&&!!t.options?.appBundleId&&t.options?.customActions!==!0&&t.options?.preferredBackend===void 0}async function os(e,t,n,r,i,a,o,s){return ss(a)&&o.add(vs(n)),J(a.code,{id:n.simulator.udid},n.generation,s,a.details),await K(n.simulator.udid,e,t,r.lineage,i,a.code,r.residue)}function ss(e){return e.kind!==`preparing`&&e.code!==ts}async function K(e,t,n,r,i,a,o=[]){return us(e,await n(t),r,i,a,o)}async function cs(e,t,n,r){let i=await n(t),a=i.systemSurface?$o:es;return i.systemSurface||J(a,e,void 0,void 0,{detectedHost:r}),us(e.id,i,ds(e.id,t),q(t),a)}async function ls(e,t,n){let r=await n(t),i=r.systemSurface;return i?{...r,comparisonIdentity:ps(fs(e.id,i.bundleId),q(t),[])}:r}function us(e,t,n,r,i,a=[]){let o=t.systemSurface;return{...t,comparisonIdentity:ps(o?fs(e,o.bundleId):n,r,[...o?[]:a,{kind:`fallback-source`,producer:`apple-runner`}]),warnings:[...t.warnings??[],ms(i,n,o!==void 0)]}}function ds(e,t){return{targetId:`${e}:${t.options.appBundleId}`}}function fs(e,t){return{targetId:`${e}:${t}`}}function ps(e,t,n){return Object.freeze({producer:`apple-runner`,intent:t.acquisitionIntent,lineage:Object.freeze({...e.targetId?{targetId:e.targetId}:{},...e.generation?{generation:e.generation}:{}}),presentationKey:fe(t),residue:Object.freeze([...n])})}function ms(e,t,n){return e===$o?`Simulator AX snapshot inapplicable (${e}); used XCTest to read the system surface presented over the app.`:e===es?`Simulator AX snapshot inapplicable (${e}); used XCTest, which read app content: the system surface host process was still running but no longer presenting.`:n?`Simulator AX snapshot unavailable (${e}); used XCTest, which read the system surface presented over the app.`:e===`bridge-preparation-pending`?`Simulator AX snapshot unavailable (${e}); used XCTest for this capture while the bridge is still being prepared.`:e===ts?`Simulator AX snapshot unavailable (${e}); used XCTest for this capture, which reports captured geometry in the app's own orientation space.`:`Simulator AX snapshot unavailable (${e}); used XCTest for ${t.generation?`this app generation`:`an unverified app generation`}.`}async function hs(e,t,n,r,i,a){if(e.kind!==`stale-target`)return{lineage:t,residue:[]};try{return{lineage:await a(n,r,i,`refresh`),residue:[]}}catch(e){return i.throwIfAborted(),J(`fallback-target-resolution-failed`,n,void 0,e),{lineage:{targetId:t.targetId},residue:[gs()]}}}function gs(){return{kind:`unknown-generation`,captureId:fn()}}function q(e){return pe({raw:e.options?.raw,interactiveOnly:e.options?.interactiveOnly,depth:e.options?.depth,scope:e.options?.scope,customActions:e.options?.customActions,acquisitionIntent:e.options?.acquisitionIntent})}function _s(e,t,n){let r=t.get(e.targetId);r&&r!==e.generation&&n.delete(`${e.targetId}:${r}`),t.set(e.targetId,e.generation)}function vs(e){return`${e.targetId}:${e.generation}`}function J(e,t,n,r,i){l({level:`debug`,phase:`ios_snapshot_route_fallback`,data:{reason:e,deviceId:t.id,...n?{generation:n}:{},...r?{error:r instanceof Error?r.message:String(r)}:{},...i?{details:i}:{}}})}const Y=ne(`apple`),X=Object.freeze({available:!0}),Z=g(`unsupported-platform-leaf`),ys=g(`unsupported-platform-leaf`,`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.`),bs=g(`unsupported-platform-leaf`,`the stateless audio page probe is a web-session operation; Apple targets use the host capture.`),xs=g(`unsupported-device-backend`,`perf requires an Apple simulator, macOS device, or CoreDevice-backed physical Apple device.`),Ss=g(`unsupported-device-kind`,`focus is supported on Apple simulators and physical devices.`),Cs=g(`unsupported-platform-leaf`,`Apple appstate is unavailable here: the runner reads the session app's XCUIApplication state on iOS-family simulators and physical devices only, and the Apple target answers no sessionless foreground probe. The per-command answer is the targetActivation disclosure, which a capture carries when its command had to re-activate the session app (#2682).`);function ws(e){return!m(e)||e.appleOs===`watchos`?Cs:e.kind===`simulator`||e.kind===`device`?X:Cs}const Ts=g(`unsupported-provider-mode`,`Headless boot is supported only for local Android emulators.`),Es=g(`unsupported-platform-leaf`,`watchOS has no XCUITest-driveable UI, so element text comes from the captured tree only.`),Ds=g(`unsupported-device-kind`),Os=g(`unsupported-platform-leaf`,`watchOS open is not supported because XCUITest cannot drive watchOS UI.`),ks=g(`unsupported-platform-leaf`,`watchOS runner preparation is not supported because XCUITest cannot drive watchOS UI.`),As=g(`unsupported-platform-leaf`,`watchOS close is not supported because XCUITest cannot drive watchOS UI.`),js=g(`unsupported-device-kind`,`Runtime hints are supported only for local iOS-family simulators and Android devices.`),Ms=Q(`open is supported only for Apple simulators and devices.`),Ns=Q(`prepare is supported only for Apple simulators and devices.`),Ps=Q(`close is supported only for Apple simulators and devices.`),Fs=g(`unsupported-provider-mode`,`Port reverse is supported only by an owning provider runtime.`),Is=g(`unsupported-device-kind`,`shutdown is supported only for Apple simulators and Android emulators.`),Ls=Q(`snapshot is supported only for Apple simulators and devices.`),Rs=g(`unsupported-platform-leaf`,`Re-run without --actions, or target an iOS simulator.`),zs=g(`unsupported-platform-leaf`,`screenshot is not supported on watchOS because XCUITest cannot drive watchOS UI.`),Bs=Q(`screenshot is supported only for Apple simulators and devices.`),Vs=g(`owner-capability-missing`,`Open the app under test before capturing its snapshot.`);function Q(e){return g(`unsupported-device-kind`,e)}function Hs(e){return!m(e)||e.appleOs===`watchos`?Z:e.kind===`simulator`?X:Is}function Us(e){let t=Ws(e),n=Gs(e),r=Ks(e),i=qs(e);return _e({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:i,clearRuntimeHints:i,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:n,configureProviderPortReverse:Fs})}function Ws(e){return u(e)===`watchos`?Os:e.kind===`simulator`||e.kind===`device`?X:Ms}function Gs(e){return u(e)===`watchos`?ks:e.kind===`simulator`||e.kind===`device`?X:Ns}function Ks(e){return u(e)===`watchos`?As:e.kind===`simulator`||e.kind===`device`?X:Ps}function qs(e){return u(e)!==`watchos`&&m(e)&&e.kind===`simulator`?X:js}function Js(e){return e.appleOs===`watchos`?g(`unsupported-platform-leaf`,`watchOS app inventory is not supported.`):e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?g(`unsupported-device-backend`,`App inventory is available only on CoreDevice-backed physical iOS devices.`):X}function $(e){return e.kind===`simulator`||e.kind===`device`?X:Ss}function Ys(e){let t=$n(e),n=ns(e),r,i=e=>p(e)?r??=$t():`xctest`,a=async n=>{let r=await t.inspectFacts(n),a=fa(n),o=Hr(n),s=o.available?await e.screenRecording.apple.availability(n):void 0,c=o.available&&s?.available===!1?g(`unsupported-provider-mode`,s.hint):o,l=n.appleOs===`watchos`?Z:X,u=p(n)||n.appleOs===`watchos`?Z:X,d=Js(n);return Object.freeze({device:r.device,operations:{...r.operations,...a,appState:ws(n),networkDump:X,screenRecordingStart:c,screenRecordingReattach:c,screenRecordingCleanup:c,...ec(n),...Ee({capture:$s(n)}),...Me({findText:Qs(n)}),...ye({setViewport:ys}),...Ue({focus:$(n)}),...Sn(n),...ve({type:$(n)}),...Ke({unsupported:Z,tap:$(n),longPress:$(n),fill:$(n),...m(n)?{tapElementSelector:$(n)}:{}}),...xe({readTextAtPoint:Zs(n)}),...Ua(n),...Bo(n),...ao(n),...We({capture:hn(n),query:bs}),...Ge(Xs(n)),ensureReady:l,bootTarget:u,bootTargetHeadless:Ts,listApps:d,...Us(n),shutdownTarget:Hs(n),...Ko(n,i(n))}})};return Object.freeze({owner:Y,ownsDevice:e=>e.platform===`apple`,inspectFacts:a,bind:async r=>{let o=await t.bind(r),s=await a(r.device),c=s.operations.screenRecordingStart,l={..._(s.operations.appState,()=>mn(e,{device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),...o.operations,...pa({host:e,device:r.device,signal:r.scope.signal}),networkDump:async t=>await rr(e,r.device,t,r.scope.signal),..._(c,()=>Ur({host:e,device:r.device,owner:Y,signal:r.scope.signal})),..._(s.operations.audioProbeStart,()=>nt({host:e.audioProbe.hostCapture,device:r.device,owner:Y})),..._(s.operations.perfFrames,()=>gn({resolveHost:()=>e.perf.apple,device:r.device,owner:Y})),..._(s.operations.captureSnapshot,()=>Ho(e,{device:r.device,signal:r.scope.signal,appBackend:i(r.device)},n)),..._(s.operations.captureScreenshot,()=>De({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),..._(s.operations.focusPoint,()=>Oe({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),...je({device:r.device,signal:r.scope.signal,facts:s.operations,resolveInteractor:e.localInteractors.resolve}),..._(s.operations.scrollDirection,()=>Ie({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),..._(s.operations.typeText,()=>Ae({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),..._(s.operations.tapPoint,()=>qe({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve,facts:s.operations,pause:async t=>await e.clock.sleep(t,r.scope.signal)})),..._(s.operations.readTextAtPoint,()=>Se({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve})),..._(s.operations.findText,()=>Uo(e,{device:r.device,signal:r.scope.signal,appBackend:i(r.device)})),...Wa({host:e,device:r.device,signal:r.scope.signal,admitted:s.operations}),...oo({host:e,device:r.device,signal:r.scope.signal}),...Vo({device:r.device,signal:r.scope.signal}),..._(s.operations.ensureReady,()=>({ensureReady:async()=>await M(e,r.device,r.scope.signal)})),..._(s.operations.bootTarget,()=>({bootTarget:async t=>await M(e,r.device,r.scope.signal,{deadlineAtMs:t.deadlineAtMs})})),..._(s.operations.listApps,()=>({listApps:async e=>{r.scope.signal.throwIfAborted();let{listIosApps:t}=await import(`./app-resolution.js`).then(e=>e.t);return(await t(e.device,e.filter)).map(e=>({id:e.bundleId,name:e.name}))}})),...he(Ri({host:e,device:r.device,signal:r.scope.signal,observation:n}),s.operations),..._(s.operations.shutdownTarget,()=>({shutdownTarget:async()=>await e.deviceShutdown.apple.shutdownTarget(r.device,r.scope.signal)}))};return Object.freeze({device:o.device,owner:Y,facts:s,operations:pn(l),[Symbol.asyncDispose]:async()=>await o[Symbol.asyncDispose]()})},shutdown:async()=>{await Promise.all([t.shutdown(),n.shutdown()])}})}function Xs(e){let t=e.iosPhysicalDeviceBackend!==`xctest`&&u(e)!==`watchos`?X:xs;return{frames:t,memorySample:t,memorySnapshot:t,nativeCapture:t,profileReport:t}}function Zs(e){return u(e)===`watchos`?Es:e.kind===`simulator`||e.kind===`device`?X:Ds}function Qs(e){return u(e)===`watchos`?Ls:e.kind===`simulator`||e.kind===`device`?X:Ls}function $s(e){return u(e)===`watchos`?zs:e.kind===`simulator`||e.kind===`device`?X:Bs}function ec(e){let t=Qs(e);return Ce({capture:t,customActions:t.available&&m(e)&&e.kind===`simulator`?X:Rs,withoutActiveApp:m(e)?Vs:t})}export{Ys as createApplePlatformRuntime};
|
package/dist/src/runtime6.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e}from"./sdk-contracts.js";import{j as t}from"./sdk-device.js";import{Xt as n,nn as r}from"./sdk-batch.js";import{n as i}from"./device-shell.js";import{n as a,t as o}from"./application-lifecycle-runtime.js";import{A as s,B as c,C as l,D as u,G as d,H as f,I as p,J as ee,K as te,L as ne,N as re,O as ie,P as ae,V as oe,d as se,h as ce,j as le,n as ue,o as de,s as fe,v as m,w as h,x as g,z as pe}from"./alert-runtime.js";import{n as me}from"./audio-probe-runtime.js";import{n as he}from"./perf-runtime.js";import{i as ge,t as _e}from"./touch-runtime.js";import{a as _,n as v}from"./durable-resource.js";import{n as ve}from"./async-lifecycle.js";import{i as ye,r as be}from"./src7.js";import{n as xe,t as y}from"./screen-recording-completion.js";import{t as b}from"./screen-recording-options.js";import{n as x}from"./screen-recording-runtime.js";import{i as S}from"./gesture-admission.js";import{t as C}from"./interactor-operation-catalog.js";import{i as w,n as T}from"./perf-runtime-operation-builder.js";import{t as E}from"./app-log-runtime.js";import{n as D,t as O}from"./application-lifecycle-interaction.js";import{randomUUID as k}from"node:crypto";import{setTimeout as A}from"node:timers/promises";const j=Object.freeze({resourceKind:E,version:1,encode:e=>({...e}),decode:e=>e.transport!==`harmony-hilog`||!N(e.outputPath)||!N(e.pidPath)?{status:`invalid`,message:`Invalid HarmonyOS app-log descriptor`}:{status:`decoded`,descriptor:Object.freeze({transport:`harmony-hilog`,outputPath:e.outputPath,pidPath:e.pidPath})}});function M(e){return v({resourceKind:E,sessionId:e.sessionId,device:{id:e.device.id,family:`harmonyos`,kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target}},owner:e.owner,fence:e.fence,lifecycle:`open`,descriptor:_(j,e.descriptor)})}function N(e){return typeof e==`string`&&e.trim().length>0}function Se(e){return be(e,{family:`harmonyos`,backend:`harmonyos`,label:`HarmonyOS`,codec:j,startUnavailableHint:`The selected HarmonyOS transport cannot start a background hilog stream.`,cleanupFailureMessage:`HarmonyOS app-log cleanup did not settle every owned resource`,doctor:async(e,t)=>({backend:`harmonyos`,checks:{},notes:t?[]:[`No app bundle is tracked in this session. Run open <app> first for app-scoped logs.`]}),process:async({host:e,device:t,input:n,signal:r})=>{let a=await Ce(e,r);return{resolvePid:async r=>await ye(e,{executable:a,args:i(`hdc`,`shell`,[`pidof`,n.appBundleId],[`-t`,t.id]),allowFailure:!0,timeoutMs:5e3},r),command:e=>({kind:`host`,request:{executable:a,args:i(`hdc`,`shell`,[`hilog`,`-P`,e],[`-t`,t.id]),allowFailure:!0}})}},descriptor:({artifacts:e})=>({transport:`harmony-hilog`,...e}),envelope:({input:e,device:t,owner:n,descriptor:r})=>M({sessionId:e.sessionId,device:t,owner:n,fence:e.fence,descriptor:r})})}async function Ce(t,n){n.throwIfAborted(),await P(async()=>await t.toolchains.prepare(`harmonyos`),n),n.throwIfAborted();let r=await P(async()=>await t.commands.which(`hdc`),n);if(n.throwIfAborted(),!r)throw new e(`TOOL_MISSING`,`hdc not found in PATH`,{hint:`Install HarmonyOS Command Line Tools, then add its sdk/default/openharmony/toolchains directory to PATH.`});return r}async function P(e,t){try{return await e()}catch(e){throw t.throwIfAborted(),e}}function we(e){let{resolveHost:t,device:n}=e,r={available:!1,reason:`Dropped-frame sampling is currently available only on Android app sessions and connected iOS device app sessions.`};return Object.freeze({perfFrames:async()=>({metric:r,sampling:r}),perfMemorySample:async({appId:e})=>({metric:e?await w(t().sampleMemory(n,e)):T(`HarmonyOS`,`bundle`),sampling:{method:`hdc-shell-proc-status`,description:`Resident memory snapshot from HarmonyOS /proc/<pid>/status. Values are reported in kilobytes.`,unit:`kB`,topConsumerLimit:1}}),perfMemorySnapshot:async({kind:e})=>({artifact:{available:!1,kind:e??`memgraph`,reason:`Memory snapshot artifacts are not supported on harmonyos.`,hint:`Use perf memory sample where supported, or run the snapshot against Android, iOS simulator, or macOS.`,support:{platform:`harmonyos`,defaultKind:`memgraph`,androidHprof:!1,memgraph:!1,heapprofd:!1}},sampling:{method:`unsupported`,description:`HarmonyOS memory snapshot capture is not available through HDC.`,artifactOnly:!0}})})}const F=Object.freeze({resourceKind:x,version:1,encode:e=>({...e}),decode:e=>e.backend===`harmony-screen-recorder`&&typeof e.fileName==`string`&&De(e.fileName)&&e.remotePath===`/data/local/tmp/${e.fileName}`?{status:`decoded`,descriptor:Object.freeze({backend:`harmony-screen-recorder`,fileName:e.fileName,remotePath:e.remotePath})}:{status:`invalid`,message:`Invalid HarmonyOS screen-recording descriptor`}});function Te(e){let{device:n,owner:r,input:i,descriptor:a}=e;return v({resourceKind:x,sessionId:i.sessionId,device:t(n),owner:r,fence:i.fence,lifecycle:`open`,descriptor:_(F,a)})}function Ee(e){return F.decode(e).status===`decoded`?{status:`cleanup-pending`,reason:`manual-recovery-required`,message:`HarmonyOS recorder ownership cannot be proven after daemon restart; no recorder was stopped.`}:{status:`cleanup-pending`,reason:`manual-recovery-required`}}function De(e){return/^agent-device-recording-[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.mp4$/i.test(e)}function Oe(e){return e.kind===`device`?Object.freeze({available:!0}):Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`HarmonyOS recording is supported on physical devices only.`})}function ke(e){let{host:t,device:n,owner:r,signal:i}=e;return Object.freeze({screenRecordingStart:async e=>await Ae({host:t,device:n,owner:r,input:e,signal:i}),screenRecordingReattach:async()=>({status:`unreattachable`,reason:`transport-not-reattachable`,message:`HarmonyOS recordings cannot be reattached after daemon restart.`}),screenRecordingCleanup:async e=>Ee(e.envelope.descriptor.body)})}async function Ae(t){let{host:n,device:r,owner:i,input:a,signal:o}=t;if(a.scope===`app`)throw new e(`INVALID_ARGS`,`HarmonyOS recording captures the whole physical-device screen; use --scope device or --scope system`);b(a,{scopes:[`device`,`system`],fps:!1,exportQuality:!1,hideTouches:!1},e=>`HarmonyOS recordings do not support ${e.join(`, `)}`),o.throwIfAborted(),await n.screenRecording.outputs.prepare(a.outputPath);let s=`agent-device-recording-${k()}.mp4`,c={backend:`harmony-screen-recorder`,fileName:s,remotePath:`/data/local/tmp/${s}`},l;try{l=await n.screenRecording.harmony.start(r,s,o),o.throwIfAborted()}catch(e){throw o.aborted?(await R(n,r,c).catch(()=>{}),o.reason):e}B(l,`start`);try{o.throwIfAborted()}catch(e){throw await R(n,r,c).catch(()=>{}),e}let u=je(a),d=!1,f=async()=>{d||=(B(await n.screenRecording.harmony.stop(r),`stop`),!0)},p=xe(u,{finish:async e=>await Me(n,r,e,c,f),forceCleanup:async()=>await R(n,r,c,f)});return Object.freeze({pendingHandle:new ve(p),envelope:Te({device:r,owner:i,input:a,descriptor:c})})}function je(e){return Object.freeze({backend:`HarmonyOS ScreenRecorder`,outPath:e.outputPath,...e.clientOutputPath===void 0?{}:{clientOutPath:e.clientOutputPath},startedAt:Date.now(),scope:e.scope,showTouches:!1,recordOnlySession:e.recordOnlySession,...e.activeSessionApp===void 0?{}:{activeSessionApp:e.activeSessionApp},gestureEvents:[]})}async function Me(e,t,n,r,i){await i();let a=await e.screenRecording.harmony.findMedia(t,r.fileName);if(!a)throw Error(`failed to find finalized HarmonyOS recording '${r.fileName}'`);if(!await Pe(e,t,r,a))throw Error(`failed to finalize HarmonyOS recording: ${r.fileName} did not produce a non-empty media file`);try{if((await e.screenRecording.harmony.pull(t,{remotePath:r.remotePath,outputPath:n.outPath})).exitCode!==0)throw Error(`failed to retrieve HarmonyOS recording`);let i=await e.screenRecording.finalize.complete({outputPath:n.outPath,showTouches:!1,gestureEvents:n.gestureEvents,targetLabel:`HarmonyOS recording`}),o=await Ne(e,t,r,a);return y(n,{...i,...L(i.warning,o)},{stopObservation:{recorder:`confirmed`},nativePathDisposition:o===void 0?`retired`:`retirable`,showTouches:!1})}catch(n){throw await e.screenRecording.harmony.remove(t,r.remotePath).catch(()=>{}),n}}async function Ne(e,t,n,r){let i=[];return await I(()=>e.screenRecording.harmony.remove(t,n.remotePath))||i.push(`staging artifact`),await I(()=>e.screenRecording.harmony.removeMedia(t,r))||i.push(`media-library artifact`),i.length===0?void 0:`HarmonyOS recording completed, but cleanup was not confirmed for the ${i.join(` and `)}.`}async function I(e){try{return await e()}catch{return!1}}function L(e,t){let n=[e,t].filter(e=>e!==void 0).join(` `);return n.length===0?{}:{warning:n}}async function Pe(e,t,n,r){let i;for(let a=0;a<40;a+=1){if(await e.screenRecording.harmony.remove(t,n.remotePath).catch(()=>{}),await e.screenRecording.harmony.stageMedia(t,{mediaUri:r,remotePath:n.remotePath})){let r=await e.screenRecording.harmony.stagedFileSize(t,n.remotePath);if(r!==void 0&&r>0&&r===i)return!0;i=r!==void 0&&r>0?r:void 0}else i=void 0;a<39&&await e.clock.sleep(250)}return!1}async function R(e,t,n,r=async()=>{B(await e.screenRecording.harmony.stop(t),`stop`)}){let i=[await z(r),await z(async()=>{if(!await e.screenRecording.harmony.remove(t,n.remotePath))throw Error(`HarmonyOS recording staging artifact removal was not confirmed`)}),await z(async()=>await Fe(e,t,n.fileName))].find(e=>e!==void 0);return i===void 0?{status:`cleaned`}:{status:`cleanup-pending`,reason:`transport-failed`,message:i instanceof Error?i.message:`HarmonyOS recording cleanup failed`}}async function Fe(e,t,n){let r=await e.screenRecording.harmony.findMedia(t,n);if(r&&!await e.screenRecording.harmony.removeMedia(t,r))throw Error(`HarmonyOS recording media removal was not confirmed`)}async function z(e){try{await e();return}catch(e){return e}}function B(e,t){if(e.exitCode===0&&e.stdout.includes(`start ability successfully`))return;let n=e.stdout.trim()||e.stderr.trim()||`hdc exit ${e.exitCode}`;throw Error(`failed to ${t} HarmonyOS screen recording: ${n}`)}async function Ie(t,n){n.throwIfAborted();let{runHarmonyShell:r}=await import(`./hdc.js`),i=await r(t,[`aa`,`dump`,`-l`],{timeoutMs:15e3,signal:n});n.throwIfAborted();let a=Le(i.stdout);if(!a)throw new e(`COMMAND_FAILED`,`Could not determine the foreground HarmonyOS app`,{hint:`Open an app on the target, then retry appstate.`});return a}function Le(e){let t=e.split(/(?=^\s*Mission ID #)/m);for(let e of t){if(!/\bstate #FOREGROUND\b/.test(e))continue;let t=e.match(/mission name #\[#([^:]+):[^:]*:([^\]]+)]/);if(!t)continue;let[,n,r]=t;if(!(!n||!r))return{package:n,activity:r}}}function Re(e){return O({owner:`HarmonyOS`,openTargetIdentity:`bundle-id`,binding:D({device:e.device,signal:e.signal,resolveInteractor:e.host.resolve})})}const ze=Object.freeze({available:!0}),Be=Object.freeze({available:!1,reason:`unsupported-device-kind`}),V=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function H(e){let t=e.kind===`emulator`||e.kind===`device`?ze:Be;return Object.freeze({deployApp:t,materializeAppSource:V,deployMaterializedApp:V,sendPushNotification:V})}function Ve(e){return H(e.device).deployApp.available?Object.freeze({deployApp:async t=>await He(e.commands,e.device,t,e.signal)}):Object.freeze({})}async function He(t,n,r,i){let a=await Ue(t,r.appPath,i)??r.app.trim();if(!a)throw new e(`INVALID_ARGS`,`Could not determine the bundle name from the HAP archive`,{hint:`Pass the HarmonyOS bundle name before the HAP path, or provide a valid HAP containing module.json.`});return await Ke(t,n,[`install`,`-r`,r.appPath],i,18e4),r.replaceExisting&&(await A(1e3,void 0,{signal:i}),await We(t,n,a,i)),{packageName:a,launchTarget:a}}async function Ue(e,t,n){let r=await e.run({executable:`unzip`,args:[`-p`,t,`module.json`],allowFailure:!0,timeoutMs:15e3},n);if(r.exitCode===0&&r.stdout.trim().length!==0)try{return JSON.parse(r.stdout).app?.bundleName?.trim()||void 0}catch{return}}async function We(t,n,r,i){let a=Ge((await U(t,n,[`bm`,`dump`,`-n`,r],i)).stdout);if(!a)throw new e(`COMMAND_FAILED`,`Could not determine a launchable ability for ${r}`,{hint:`Check that the HarmonyOS bundle exposes a main ability.`});await U(t,n,[`aa`,`start`,`-b`,r,...a.module?[`-m`,a.module]:[],`-a`,a.ability],i)}function Ge(e){let t=e.indexOf(`{`);if(t!==-1)try{let n=JSON.parse(e.slice(t)).hapModuleInfos?.find(e=>e.mainElementName);return n?.mainElementName?{ability:n.mainElementName,...n.moduleName?{module:n.moduleName}:{}}:void 0}catch{return}}async function Ke(e,t,n,r,i=15e3){return await e.run({executable:`hdc`,args:[`-t`,t.id,...n],timeoutMs:i},r)}async function U(e,t,n,r,a=15e3){return await e.run({executable:`hdc`,args:i(`hdc`,`shell`,n,[`-t`,t.id]),timeoutMs:a},r)}const W=n(`harmonyos`),qe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`HarmonyOS reads element text from the captured tree only.`}),Je=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`focus is supported on HarmonyOS emulators and physical devices.`}),G=Object.freeze({available:!0}),K=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),Ye=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`HarmonyOS appstate is supported only for HarmonyOS emulators and devices.`}),Xe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Apple runner preparation is supported only for Apple targets.`}),q=Object.freeze({available:!0}),Ze=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`open is supported only for HarmonyOS emulators and devices.`}),Qe=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`close is supported only for HarmonyOS emulators and devices.`}),$e=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Port reverse is supported only by an owning provider runtime.`}),J=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`snapshot is supported only for HarmonyOS emulators and devices.`}),et=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`screenshot is supported only for HarmonyOS emulators and devices.`}),tt=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Re-run without --actions, or target an iOS simulator.`}),nt=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`viewport resizes web targets only (--platform web).`});function rt(e){let t=it(e),n=at(e);return o({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:K,clearRuntimeHints:K,closeApplication:n,finalizeApplicationClose:n,prepareAppleRunner:Xe,configureProviderPortReverse:$e})}function it(e){return e.kind===`emulator`||e.kind===`device`?q:Ze}function at(e){return e.kind===`emulator`||e.kind===`device`?q:Qe}const Y=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`Gestures are supported on HarmonyOS emulators and physical devices.`}),ot=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),st=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:S});function X(e){return e.kind===`emulator`||e.kind===`device`?G:Y}function Z(e){return e.kind===`emulator`||e.kind===`device`?G:Je}const Q=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),ct=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`keyboard status/get is not available through the public HarmonyOS HDC API; use keyboard dismiss or enter`}),$=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`audio is supported for web browser sessions, macOS sessions, iOS simulators, and Android emulators on macOS hosts`});function lt(e){let t=Se(e),n=async e=>{let n=await t.inspectFacts(e),r=H(e),i=Oe(e);return Object.freeze({device:n.device,operations:{...n.operations,...r,appState:e.kind===`simulator`?Ye:G,networkDump:K,screenRecordingStart:i,screenRecordingReattach:i,screenRecordingCleanup:i,...d({capture:e.kind===`emulator`||e.kind===`device`?G:J,customActions:tt,withoutActiveApp:e.kind===`emulator`||e.kind===`device`?G:J}),...ee({capture:e.kind===`emulator`||e.kind===`device`?G:et}),...oe({findText:J}),...c({setViewport:nt}),...pe({focus:Z(e)}),...p({unsupported:Y,plan:X(e),directionalFling:X(e),multiTouch:ot,targetAuthoredDrag:st,viewport:X(e)}),...re({scroll:X(e)}),...s({type:Z(e)}),...ge({unsupported:K,tap:Z(e),longPress:Z(e),fill:Z(e)}),...u({readTextAtPoint:qe}),...h({back:Z(e)}),...se({unsupported:Q,home:Z(e),appSwitcher:Z(e)}),setFoldPose:Q,...fe({triggerAppEvent:Q}),...de({setSetting:Z(e),readSetting:Q}),...ue({read:Q,wait:Q,accept:Q,dismiss:Q}),...l({orientation:Q}),...g({tvRemote:Q}),...m({unsupported:Q,status:ct,dismiss:Z(e),enter:Z(e)}),...ce({unsupported:Q}),...me({capture:$,query:$}),...he({frames:Z(e),memorySample:Z(e),memorySnapshot:Z(e),nativeCapture:Q,profileReport:Q}),ensureReady:G,bootTarget:K,bootTargetHeadless:K,listApps:G,...rt(e),shutdownTarget:K}})};return Object.freeze({owner:W,ownsDevice:e=>e.platform===`harmonyos`,inspectFacts:n,bind:async i=>{let o=await t.bind(i),s=await n(i.device),c=s.operations.screenRecordingStart;return Object.freeze({device:o.device,owner:W,facts:s,operations:Object.freeze({...o.operations,...Ve({commands:e.commands,device:i.device,signal:i.scope.signal}),...s.operations.appState.available?{appState:async()=>await Ie(i.device,i.scope.signal)}:{},ensureReady:async()=>({...i.device,booted:!0}),...c.available?ke({host:e,device:i.device,owner:W,signal:i.scope.signal}):{},...s.operations.captureSnapshot.available?f({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...s.operations.captureScreenshot.available?te({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...s.operations.focusPoint.available?ne({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...s.operations.typeText.available?ie({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...ae({device:i.device,signal:i.scope.signal,facts:s.operations,resolveInteractor:e.localInteractors.resolve}),...s.operations.scrollDirection.available?le({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...C({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve,facts:s.operations}),...r(s.operations.perfFrames,()=>we({resolveHost:()=>e.perf.harmony,device:i.device})),...r(s.operations.tapPoint,()=>_e({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve,facts:s.operations,pause:async t=>await e.clock.sleep(t,i.scope.signal)})),listApps:async e=>{i.scope.signal.throwIfAborted();let{listHarmonyApps:t}=await import(`./app-lifecycle2.js`);return(await t(e.device,e.filter,{signal:i.scope.signal})).map(e=>({id:e.package,name:e.name}))},...a(Re({host:e.localInteractors,device:i.device,signal:i.scope.signal}),s.operations)}),[Symbol.asyncDispose]:async()=>await o[Symbol.asyncDispose]()})},shutdown:async()=>await t.shutdown()})}export{lt as createHarmonyPlatformRuntime};
|
|
1
|
+
import{J as e}from"./sdk-contracts.js";import{h as t}from"./sdk-device.js";import{s as n}from"./simctl.js";import{t as r}from"./simulator-state.js";const i=15e3;function a(e){return Object.freeze({canShutdownTarget:o,shutdownTarget:async(t,n)=>await s(e.appleTools,t,n)})}function o(e){return t(e)&&e.appleOs!==`watchos`&&e.kind===`simulator`}async function s(t,r,a){a.throwIfAborted();try{let e=await t.run({tool:`simctl`,args:n(r,[`shutdown`,r.id]),allowFailure:!0,timeoutMs:i},a);a.throwIfAborted();let o=l(e);return o.success?o:await c(t,r,a)===`Shutdown`?{...o,success:!0,exitCode:0}:o}catch(t){a.throwIfAborted();let n=e(t);return{success:!1,exitCode:-1,stdout:``,stderr:n.message,error:n}}}async function c(e,t,n){try{return await r(e,t,n,i)}catch{return n.throwIfAborted(),null}}function l(e){let t=e.exitCode??-1;return{success:t===0,exitCode:t,stdout:e.stdout,stderr:e.stderr}}export{a as createAppleShutdownRuntime};
|
package/dist/src/runtime7.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e}from"./sdk-contracts.js";import{Xt as t,tn as n}from"./sdk-batch.js";import{n as r,t as i}from"./application-lifecycle-runtime.js";import{A as a,D as o,G as s,I as c,J as ee,N as l,W as u,d,h as f,w as p,z as m}from"./alert-runtime.js";import{i as h}from"./touch-runtime.js";import{r as g}from"./platform-runtime-unavailable.js";import{i as _}from"./gesture-admission.js";import{t as v}from"./local-interactor-operation-set.js";import{n as y,t as b}from"./application-lifecycle-interaction.js";function x(e){return b({owner:`Linux`,openTargetIdentity:`app-name`,binding:y({device:e.device,signal:e.signal,resolveInteractor:e.host.resolve})})}const S=Object.freeze({available:!0}),C=t(`linux`),w=$(`unsupported-platform-leaf`),T=$(`unsupported-device-kind`),E=$(`unsupported-device-kind`,`focus is supported only for the Linux desktop device.`),D=$(`unsupported-device-kind`,`type is supported only for the Linux desktop device.`),O=$(`unsupported-device-kind`,`Gestures are supported only for the Linux desktop device.`),k=$(`unsupported-device-kind`,`scroll is supported only for the Linux desktop device.`),A=$(`unsupported-platform-leaf`),j=$(`unsupported-platform-leaf`),M=$(`unsupported-platform-leaf`,_),N=$(`unsupported-platform-leaf`),P=$(`unsupported-platform-leaf`,`Runtime hints are supported only for local iOS-family simulators and Android devices.`),F=$(`unsupported-platform-leaf`,`Apple runner preparation is supported only for Apple targets.`),I=$(`unsupported-provider-mode`,`Port reverse is supported only by an owning provider runtime.`),L=$(`unsupported-device-kind`,`open is supported only for the Linux desktop device.`),R=$(`unsupported-device-kind`,`close is supported only for the Linux desktop device.`),z=$(`unsupported-device-kind`,`snapshot is supported only for the Linux desktop device.`),B=$(`unsupported-device-kind`,`screenshot is supported only for the Linux desktop device.`),V=$(`unsupported-platform-leaf`,`Re-run without --actions, or target an iOS simulator.`),H=$(`unsupported-device-kind`,`back is supported only for the Linux desktop device.`),U=$(`unsupported-device-kind`,`home is supported only for the Linux desktop device.`),W=$(`unsupported-device-kind`,`clipboard is supported only for the Linux desktop device.`),G=w,K=$(`unsupported-platform-leaf`,`audio is supported for web browser sessions, macOS sessions, iOS simulators, and Android emulators on macOS hosts`);function q(t){return Object.freeze({owner:C,ownsDevice:e=>e.platform===`linux`,inspectFacts:async e=>Y(e),bind:async i=>{if(i.intent.kind===`exact-owner`&&!n(i.intent.owner,C))throw new e(`UNSUPPORTED_OPERATION`,`Linux runtime owner identity does not match`);if(i.device.platform!==`linux`)throw new e(`UNSUPPORTED_PLATFORM`,`Linux runtime cannot bind this device`);let a=Y(i.device),o=x({host:t.localInteractors,device:i.device,signal:i.scope.signal});return Object.freeze({device:i.device,owner:C,facts:a,operations:Object.freeze({...r(o,a.operations),...a.operations.captureSnapshot.available?Q(t,i):{},...J(t,i,a)}),[Symbol.asyncDispose]:async()=>void 0})},shutdown:async()=>void 0})}function J(e,t,n){let r={device:t.device,signal:t.scope.signal,resolveInteractor:e.localInteractors.resolve};return v({...r,facts:n.operations,pause:async n=>await e.clock.sleep(n,t.scope.signal)})}function Y(e){let t=e.kind===`device`?S:L,n=e.kind===`device`?S:R,r=g(e,C,{appLog:w,network:w,screenshot:B,snapshot:z,viewport:w,focus:E,gesture:O,scroll:k,typeText:D,touch:E,elementText:T,back:H,orientation:G,tvRemote:G,clipboard:W,systemButton:G,fold:G,triggerAppEvent:G,settings:G,readAlert:G,awaitAlert:G,acceptAlert:G,dismissAlert:G,keyboard:G,audioProbeCapture:K,audioProbeQuery:K,perf:G,readiness:w,lifecycle:i({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:P,clearRuntimeHints:P,closeApplication:n,finalizeApplicationClose:n,prepareAppleRunner:F,configureProviderPortReverse:I})});return Object.freeze({device:r.device,operations:{...r.operations,...s({capture:X(e,z),customActions:V,withoutActiveApp:X(e,z)}),...ee({capture:X(e,B)}),...m({focus:X(e,E)}),...c({unsupported:O,plan:X(e,O),directionalFling:A,multiTouch:j,targetAuthoredDrag:M,viewport:N}),...l({scroll:X(e,k)}),...a({type:X(e,D)}),...Z(e),...o({readTextAtPoint:X(e,T)}),...p({back:X(e,H)}),...d({unsupported:G,home:X(e,U)}),...f({unsupported:W,read:X(e,W),write:X(e,W)})}})}function X(e,t){return e.kind===`device`?S:t}function Z(e){let t=e.kind===`device`?S:E;return h({unsupported:w,tap:t,longPress:t,fill:t})}function Q(e,t){let n=async n=>await e.snapshot.captureSurface(t.device,n.options,u(t.scope.signal,n));return Object.freeze({captureSnapshot:n,captureSnapshotWithCustomActions:n,captureSnapshotWithoutActiveApp:n})}function $(e,t){return Object.freeze(t===void 0?{available:!1,reason:e}:{available:!1,reason:e,hint:t})}export{q as createLinuxPlatformRuntime};
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";import{N as t}from"./sdk-device.js";import{Xt as n,nn as r,rn as i}from"./sdk-batch.js";import{n as a}from"./device-shell.js";import{n as o,t as s}from"./application-lifecycle-runtime.js";import{A as c,B as l,C as u,D as d,G as f,H as p,I as ee,J as te,N as ne,V as re,d as ie,h as ae,n as oe,o as se,s as ce,v as le,w as ue,x as m,z as h}from"./alert-runtime.js";import{n as de}from"./audio-probe-runtime.js";import{n as g}from"./perf-runtime.js";import{i as _}from"./touch-runtime.js";import{a as v,n as y}from"./durable-resource.js";import{n as b}from"./async-lifecycle.js";import{i as fe,r as pe}from"./src7.js";import{n as me,t as he}from"./screen-recording-completion.js";import{t as ge}from"./screen-recording-options.js";import{n as x}from"./screen-recording-runtime.js";import{i as _e}from"./gesture-admission.js";import{t as ve}from"./local-interactor-operation-set.js";import{i as S,n as C}from"./perf-runtime-operation-builder.js";import{t as w}from"./app-log-runtime.js";import{r as T}from"./application-lifecycle-interaction.js";import{randomUUID as E}from"node:crypto";import{setTimeout as D}from"node:timers/promises";const O=Object.freeze({resourceKind:w,version:1,encode:e=>({...e}),decode:e=>e.transport!==`harmony-hilog`||!A(e.outputPath)||!A(e.pidPath)?{status:`invalid`,message:`Invalid HarmonyOS app-log descriptor`}:{status:`decoded`,descriptor:Object.freeze({transport:`harmony-hilog`,outputPath:e.outputPath,pidPath:e.pidPath})}});function k(e){return y({resourceKind:w,sessionId:e.sessionId,device:{id:e.device.id,family:`harmonyos`,kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target}},owner:e.owner,fence:e.fence,lifecycle:`open`,descriptor:v(O,e.descriptor)})}function A(e){return typeof e==`string`&&e.trim().length>0}function j(e){return pe(e,{family:`harmonyos`,backend:`harmonyos`,label:`HarmonyOS`,codec:O,startUnavailableHint:`The selected HarmonyOS transport cannot start a background hilog stream.`,cleanupFailureMessage:`HarmonyOS app-log cleanup did not settle every owned resource`,doctor:async(e,t)=>({backend:`harmonyos`,checks:{},notes:t?[]:[`No app bundle is tracked in this session. Run open <app> first for app-scoped logs.`]}),process:async({host:e,device:t,input:n,signal:r})=>{let i=await M(e,r);return{resolvePid:async r=>await fe(e,{executable:i,args:a(`hdc`,`shell`,[`pidof`,n.appBundleId],[`-t`,t.id]),allowFailure:!0,timeoutMs:5e3},r),command:e=>({kind:`host`,request:{executable:i,args:a(`hdc`,`shell`,[`hilog`,`-P`,e],[`-t`,t.id]),allowFailure:!0}})}},descriptor:({artifacts:e})=>({transport:`harmony-hilog`,...e}),envelope:({input:e,device:t,owner:n,descriptor:r})=>k({sessionId:e.sessionId,device:t,owner:n,fence:e.fence,descriptor:r})})}async function M(t,n){n.throwIfAborted(),await N(async()=>await t.toolchains.prepare(`harmonyos`),n),n.throwIfAborted();let r=await N(async()=>await t.commands.which(`hdc`),n);if(n.throwIfAborted(),!r)throw new e(`TOOL_MISSING`,`hdc not found in PATH`,{hint:`Install HarmonyOS Command Line Tools, then add its sdk/default/openharmony/toolchains directory to PATH.`});return r}async function N(e,t){try{return await e()}catch(e){throw t.throwIfAborted(),e}}function P(e){let{resolveHost:t,device:n}=e,r={available:!1,reason:`Dropped-frame sampling is currently available only on Android app sessions and connected iOS device app sessions.`};return Object.freeze({perfFrames:async()=>({metric:r,sampling:r}),perfMemorySample:async({appId:e})=>({metric:e?await S(t().sampleMemory(n,e)):C(`HarmonyOS`,`bundle`),sampling:{method:`hdc-shell-proc-status`,description:`Resident memory snapshot from HarmonyOS /proc/<pid>/status. Values are reported in kilobytes.`,unit:`kB`,topConsumerLimit:1}}),perfMemorySnapshot:async({kind:e})=>({artifact:{available:!1,kind:e??`memgraph`,reason:`Memory snapshot artifacts are not supported on harmonyos.`,hint:`Use perf memory sample where supported, or run the snapshot against Android, iOS simulator, or macOS.`,support:{platform:`harmonyos`,defaultKind:`memgraph`,androidHprof:!1,memgraph:!1,heapprofd:!1}},sampling:{method:`unsupported`,description:`HarmonyOS memory snapshot capture is not available through HDC.`,artifactOnly:!0}})})}const F=Object.freeze({resourceKind:x,version:1,encode:e=>({...e}),decode:e=>e.backend===`harmony-screen-recorder`&&typeof e.fileName==`string`&&xe(e.fileName)&&e.remotePath===`/data/local/tmp/${e.fileName}`?{status:`decoded`,descriptor:Object.freeze({backend:`harmony-screen-recorder`,fileName:e.fileName,remotePath:e.remotePath})}:{status:`invalid`,message:`Invalid HarmonyOS screen-recording descriptor`}});function ye(e){let{device:n,owner:r,input:i,descriptor:a}=e;return y({resourceKind:x,sessionId:i.sessionId,device:t(n),owner:r,fence:i.fence,lifecycle:`open`,descriptor:v(F,a)})}function be(e){return F.decode(e).status===`decoded`?{status:`cleanup-pending`,reason:`manual-recovery-required`,message:`HarmonyOS recorder ownership cannot be proven after daemon restart; no recorder was stopped.`}:{status:`cleanup-pending`,reason:`manual-recovery-required`}}function xe(e){return/^agent-device-recording-[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.mp4$/i.test(e)}function Se(e){return e.kind===`device`?Object.freeze({available:!0}):Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`HarmonyOS recording is supported on physical devices only.`})}function Ce(e){let{host:t,device:n,owner:r,signal:i}=e;return Object.freeze({screenRecordingStart:async e=>await we({host:t,device:n,owner:r,input:e,signal:i}),screenRecordingReattach:async()=>({status:`unreattachable`,reason:`transport-not-reattachable`,message:`HarmonyOS recordings cannot be reattached after daemon restart.`}),screenRecordingCleanup:async e=>be(e.envelope.descriptor.body)})}async function we(t){let{host:n,device:r,owner:i,input:a,signal:o}=t;if(a.scope===`app`)throw new e(`INVALID_ARGS`,`HarmonyOS recording captures the whole physical-device screen; use --scope device or --scope system`);ge(a,{scopes:[`device`,`system`],fps:!1,exportQuality:!1,hideTouches:!1},e=>`HarmonyOS recordings do not support ${e.join(`, `)}`),o.throwIfAborted(),await n.screenRecording.outputs.prepare(a.outputPath);let s=`agent-device-recording-${E()}.mp4`,c={backend:`harmony-screen-recorder`,fileName:s,remotePath:`/data/local/tmp/${s}`},l;try{l=await n.screenRecording.harmony.start(r,s,o),o.throwIfAborted()}catch(e){throw o.aborted?(await L(n,r,c).catch(()=>{}),o.reason):e}z(l,`start`);try{o.throwIfAborted()}catch(e){throw await L(n,r,c).catch(()=>{}),e}let u=Te(a),d=!1,f=async()=>{d||=(z(await n.screenRecording.harmony.stop(r),`stop`),!0)},p=me(u,{finish:async e=>await Ee(n,r,e,c,f),forceCleanup:async()=>await L(n,r,c,f)});return Object.freeze({pendingHandle:new b(p),envelope:ye({device:r,owner:i,input:a,descriptor:c})})}function Te(e){return Object.freeze({backend:`HarmonyOS ScreenRecorder`,outPath:e.outputPath,...e.clientOutputPath===void 0?{}:{clientOutPath:e.clientOutputPath},startedAt:Date.now(),scope:e.scope,showTouches:!1,recordOnlySession:e.recordOnlySession,...e.activeSessionApp===void 0?{}:{activeSessionApp:e.activeSessionApp},gestureEvents:[]})}async function Ee(e,t,n,r,i){await i();let a=await e.screenRecording.harmony.findMedia(t,r.fileName);if(!a)throw Error(`failed to find finalized HarmonyOS recording '${r.fileName}'`);if(!await ke(e,t,r,a))throw Error(`failed to finalize HarmonyOS recording: ${r.fileName} did not produce a non-empty media file`);try{if((await e.screenRecording.harmony.pull(t,{remotePath:r.remotePath,outputPath:n.outPath})).exitCode!==0)throw Error(`failed to retrieve HarmonyOS recording`);let i=await e.screenRecording.finalize.complete({outputPath:n.outPath,showTouches:!1,gestureEvents:n.gestureEvents,targetLabel:`HarmonyOS recording`}),o=await De(e,t,r,a);return he(n,{...i,...Oe(i.warning,o)},{stopObservation:{recorder:`confirmed`},nativePathDisposition:o===void 0?`retired`:`retirable`,showTouches:!1})}catch(n){throw await e.screenRecording.harmony.remove(t,r.remotePath).catch(()=>{}),n}}async function De(e,t,n,r){let i=[];return await I(()=>e.screenRecording.harmony.remove(t,n.remotePath))||i.push(`staging artifact`),await I(()=>e.screenRecording.harmony.removeMedia(t,r))||i.push(`media-library artifact`),i.length===0?void 0:`HarmonyOS recording completed, but cleanup was not confirmed for the ${i.join(` and `)}.`}async function I(e){try{return await e()}catch{return!1}}function Oe(e,t){let n=[e,t].filter(e=>e!==void 0).join(` `);return n.length===0?{}:{warning:n}}async function ke(e,t,n,r){let i;for(let a=0;a<40;a+=1){if(await e.screenRecording.harmony.remove(t,n.remotePath).catch(()=>{}),await e.screenRecording.harmony.stageMedia(t,{mediaUri:r,remotePath:n.remotePath})){let r=await e.screenRecording.harmony.stagedFileSize(t,n.remotePath);if(r!==void 0&&r>0&&r===i)return!0;i=r!==void 0&&r>0?r:void 0}else i=void 0;a<39&&await e.clock.sleep(250)}return!1}async function L(e,t,n,r=async()=>{z(await e.screenRecording.harmony.stop(t),`stop`)}){let i=[await R(r),await R(async()=>{if(!await e.screenRecording.harmony.remove(t,n.remotePath))throw Error(`HarmonyOS recording staging artifact removal was not confirmed`)}),await R(async()=>await Ae(e,t,n.fileName))].find(e=>e!==void 0);return i===void 0?{status:`cleaned`}:{status:`cleanup-pending`,reason:`transport-failed`,message:i instanceof Error?i.message:`HarmonyOS recording cleanup failed`}}async function Ae(e,t,n){let r=await e.screenRecording.harmony.findMedia(t,n);if(r&&!await e.screenRecording.harmony.removeMedia(t,r))throw Error(`HarmonyOS recording media removal was not confirmed`)}async function R(e){try{await e();return}catch(e){return e}}function z(e,t){if(e.exitCode===0&&e.stdout.includes(`start ability successfully`))return;let n=e.stdout.trim()||e.stderr.trim()||`hdc exit ${e.exitCode}`;throw Error(`failed to ${t} HarmonyOS screen recording: ${n}`)}async function je(t,n){n.throwIfAborted();let{runHarmonyShell:r}=await import(`./hdc.js`),i=await r(t,[`aa`,`dump`,`-l`],{timeoutMs:15e3,signal:n});n.throwIfAborted();let a=Me(i.stdout);if(!a)throw new e(`COMMAND_FAILED`,`Could not determine the foreground HarmonyOS app`,{hint:`Open an app on the target, then retry appstate.`});return a}function Me(e){let t=e.split(/(?=^\s*Mission ID #)/m);for(let e of t){if(!/\bstate #FOREGROUND\b/.test(e))continue;let t=e.match(/mission name #\[#([^:]+):[^:]*:([^\]]+)]/);if(!t)continue;let[,n,r]=t;if(!(!n||!r))return{package:n,activity:r}}}const Ne=Object.freeze({available:!0}),B=Object.freeze({available:!1,reason:`unsupported-device-kind`}),V=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function H(e){let t=e.kind===`emulator`||e.kind===`device`?Ne:B;return Object.freeze({deployApp:t,materializeAppSource:V,deployMaterializedApp:V,sendPushNotification:V})}function Pe(e){return H(e.device).deployApp.available?Object.freeze({deployApp:async t=>await Fe(e.commands,e.device,t,e.signal)}):Object.freeze({})}async function Fe(t,n,r,i){let a=await Ie(t,r.appPath,i)??r.app.trim();if(!a)throw new e(`INVALID_ARGS`,`Could not determine the bundle name from the HAP archive`,{hint:`Pass the HarmonyOS bundle name before the HAP path, or provide a valid HAP containing module.json.`});return await ze(t,n,[`install`,`-r`,r.appPath],i,18e4),r.replaceExisting&&(await D(1e3,void 0,{signal:i}),await Le(t,n,a,i)),{packageName:a,launchTarget:a}}async function Ie(e,t,n){let r=await e.run({executable:`unzip`,args:[`-p`,t,`module.json`],allowFailure:!0,timeoutMs:15e3},n);if(r.exitCode===0&&r.stdout.trim().length!==0)try{return JSON.parse(r.stdout).app?.bundleName?.trim()||void 0}catch{return}}async function Le(t,n,r,i){let a=Re((await U(t,n,[`bm`,`dump`,`-n`,r],i)).stdout);if(!a)throw new e(`COMMAND_FAILED`,`Could not determine a launchable ability for ${r}`,{hint:`Check that the HarmonyOS bundle exposes a main ability.`});await U(t,n,[`aa`,`start`,`-b`,r,...a.module?[`-m`,a.module]:[],`-a`,a.ability],i)}function Re(e){let t=e.indexOf(`{`);if(t!==-1)try{let n=JSON.parse(e.slice(t)).hapModuleInfos?.find(e=>e.mainElementName);return n?.mainElementName?{ability:n.mainElementName,...n.moduleName?{module:n.moduleName}:{}}:void 0}catch{return}}async function ze(e,t,n,r,i=15e3){return await e.run({executable:`hdc`,args:[`-t`,t.id,...n],timeoutMs:i},r)}async function U(e,t,n,r,i=15e3){return await e.run({executable:`hdc`,args:a(`hdc`,`shell`,n,[`-t`,t.id]),timeoutMs:i},r)}const W=n(`harmonyos`),Be=r(`unsupported-platform-leaf`,`HarmonyOS reads element text from the captured tree only.`),Ve=r(`unsupported-device-kind`,`focus is supported on HarmonyOS emulators and physical devices.`),G=Object.freeze({available:!0}),K=r(`unsupported-platform-leaf`),He=r(`unsupported-device-kind`,`HarmonyOS appstate is supported only for HarmonyOS emulators and devices.`),Ue=r(`unsupported-platform-leaf`,`Apple runner preparation is supported only for Apple targets.`),q=Object.freeze({available:!0}),We=r(`unsupported-device-kind`,`open is supported only for HarmonyOS emulators and devices.`),Ge=r(`unsupported-device-kind`,`close is supported only for HarmonyOS emulators and devices.`),Ke=r(`unsupported-provider-mode`,`Port reverse is supported only by an owning provider runtime.`),J=r(`unsupported-device-kind`,`snapshot is supported only for HarmonyOS emulators and devices.`),qe=r(`unsupported-device-kind`,`screenshot is supported only for HarmonyOS emulators and devices.`),Je=r(`unsupported-platform-leaf`,`Re-run without --actions, or target an iOS simulator.`),Ye=r(`unsupported-platform-leaf`,`viewport resizes web targets only (--platform web).`);function Xe(e){let t=Ze(e),n=Qe(e);return s({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:K,clearRuntimeHints:K,closeApplication:n,finalizeApplicationClose:n,prepareAppleRunner:Ue,configureProviderPortReverse:Ke})}function Ze(e){return e.kind===`emulator`||e.kind===`device`?q:We}function Qe(e){return e.kind===`emulator`||e.kind===`device`?q:Ge}const Y=r(`unsupported-device-kind`,`Gestures are supported on HarmonyOS emulators and physical devices.`),$e=r(`unsupported-platform-leaf`),et=r(`unsupported-platform-leaf`,_e);function X(e){return e.kind===`emulator`||e.kind===`device`?G:Y}function Z(e){return e.kind===`emulator`||e.kind===`device`?G:Ve}const Q=r(`unsupported-platform-leaf`),tt=r(`unsupported-platform-leaf`,`keyboard status/get is not available through the public HarmonyOS HDC API; use keyboard dismiss or enter`),$=r(`unsupported-platform-leaf`,`audio is supported for web browser sessions, macOS sessions, iOS simulators, and Android emulators on macOS hosts`);function nt(e){let t=j(e),n=async e=>{let n=await t.inspectFacts(e),r=H(e),i=Se(e);return Object.freeze({device:n.device,operations:{...n.operations,...r,appState:e.kind===`simulator`?He:G,networkDump:K,screenRecordingStart:i,screenRecordingReattach:i,screenRecordingCleanup:i,...f({capture:e.kind===`emulator`||e.kind===`device`?G:J,customActions:Je,withoutActiveApp:e.kind===`emulator`||e.kind===`device`?G:J}),...te({capture:e.kind===`emulator`||e.kind===`device`?G:qe}),...re({findText:J}),...l({setViewport:Ye}),...h({focus:Z(e)}),...ee({unsupported:Y,plan:X(e),directionalFling:X(e),multiTouch:$e,targetAuthoredDrag:et,viewport:X(e)}),...ne({scroll:X(e)}),...c({type:Z(e)}),..._({unsupported:K,tap:Z(e),longPress:Z(e),fill:Z(e)}),...d({readTextAtPoint:Be}),...ue({back:Z(e)}),...ie({unsupported:Q,home:Z(e),appSwitcher:Z(e)}),setFoldPose:Q,...ce({triggerAppEvent:Q}),...se({setSetting:Z(e),readSetting:Q}),...oe({read:Q,wait:Q,accept:Q,dismiss:Q}),...u({orientation:Q}),...m({tvRemote:Q}),...le({unsupported:Q,status:tt,dismiss:Z(e),enter:Z(e)}),...ae({unsupported:Q}),...de({capture:$,query:$}),...g({frames:Z(e),memorySample:Z(e),memorySnapshot:Z(e),nativeCapture:Q,profileReport:Q}),ensureReady:G,bootTarget:K,bootTargetHeadless:K,listApps:G,...Xe(e),shutdownTarget:K}})};return Object.freeze({owner:W,ownsDevice:e=>e.platform===`harmonyos`,inspectFacts:n,bind:async r=>{let a=await t.bind(r),s=await n(r.device),c=s.operations.screenRecordingStart;return Object.freeze({device:a.device,owner:W,facts:s,operations:Object.freeze({...a.operations,...Pe({commands:e.commands,device:r.device,signal:r.scope.signal}),...s.operations.appState.available?{appState:async()=>await je(r.device,r.scope.signal)}:{},ensureReady:async()=>({...r.device,booted:!0}),...c.available?Ce({host:e,device:r.device,owner:W,signal:r.scope.signal}):{},...s.operations.captureSnapshot.available?p({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...ve({device:r.device,signal:r.scope.signal,resolveInteractor:e.localInteractors.resolve,facts:s.operations,pause:async t=>await e.clock.sleep(t,r.scope.signal)}),...i(s.operations.perfFrames,()=>P({resolveHost:()=>e.perf.harmony,device:r.device})),listApps:async e=>{r.scope.signal.throwIfAborted();let{listHarmonyApps:t}=await import(`./app-lifecycle2.js`);return(await t(e.device,e.filter,{signal:r.scope.signal})).map(e=>({id:e.package,name:e.name}))},...o(T({owner:`HarmonyOS`,openTargetIdentity:`bundle-id`,host:e.localInteractors,device:r.device,signal:r.scope.signal}),s.operations)}),[Symbol.asyncDispose]:async()=>await a[Symbol.asyncDispose]()})},shutdown:async()=>await t.shutdown()})}export{nt as createHarmonyPlatformRuntime};
|
package/dist/src/runtime8.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e}from"./sdk-contracts.js";import{Xt as t,tn as
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";import{Xt as t,nn as n,tn as r}from"./sdk-batch.js";import{n as i,t as a}from"./application-lifecycle-runtime.js";import{A as o,D as s,G as c,I as l,J as u,N as d,W as f,d as p,h as m,w as h,z as g}from"./alert-runtime.js";import{i as _}from"./touch-runtime.js";import{r as v}from"./platform-runtime-unavailable.js";import{i as y}from"./gesture-admission.js";import{t as b}from"./local-interactor-operation-set.js";import{r as x}from"./application-lifecycle-interaction.js";const S=Object.freeze({available:!0}),C=t(`linux`),w=n(`unsupported-platform-leaf`),T=n(`unsupported-device-kind`),E=n(`unsupported-device-kind`,`focus is supported only for the Linux desktop device.`),D=n(`unsupported-device-kind`,`type is supported only for the Linux desktop device.`),O=n(`unsupported-device-kind`,`Gestures are supported only for the Linux desktop device.`),k=n(`unsupported-device-kind`,`scroll is supported only for the Linux desktop device.`),A=n(`unsupported-platform-leaf`),j=n(`unsupported-platform-leaf`),M=n(`unsupported-platform-leaf`,y),N=n(`unsupported-platform-leaf`),P=n(`unsupported-platform-leaf`,`Runtime hints are supported only for local iOS-family simulators and Android devices.`),F=n(`unsupported-platform-leaf`,`Apple runner preparation is supported only for Apple targets.`),I=n(`unsupported-provider-mode`,`Port reverse is supported only by an owning provider runtime.`),L=n(`unsupported-device-kind`,`open is supported only for the Linux desktop device.`),R=n(`unsupported-device-kind`,`close is supported only for the Linux desktop device.`),z=n(`unsupported-device-kind`,`snapshot is supported only for the Linux desktop device.`),B=n(`unsupported-device-kind`,`screenshot is supported only for the Linux desktop device.`),V=n(`unsupported-platform-leaf`,`Re-run without --actions, or target an iOS simulator.`),H=n(`unsupported-device-kind`,`back is supported only for the Linux desktop device.`),U=n(`unsupported-device-kind`,`home is supported only for the Linux desktop device.`),W=n(`unsupported-device-kind`,`clipboard is supported only for the Linux desktop device.`),G=w,K=n(`unsupported-platform-leaf`,`audio is supported for web browser sessions, macOS sessions, iOS simulators, and Android emulators on macOS hosts`);function q(t){return Object.freeze({owner:C,ownsDevice:e=>e.platform===`linux`,inspectFacts:async e=>Y(e),bind:async n=>{if(n.intent.kind===`exact-owner`&&!r(n.intent.owner,C))throw new e(`UNSUPPORTED_OPERATION`,`Linux runtime owner identity does not match`);if(n.device.platform!==`linux`)throw new e(`UNSUPPORTED_PLATFORM`,`Linux runtime cannot bind this device`);let a=Y(n.device),o=x({owner:`Linux`,openTargetIdentity:`app-name`,host:t.localInteractors,device:n.device,signal:n.scope.signal});return Object.freeze({device:n.device,owner:C,facts:a,operations:Object.freeze({...i(o,a.operations),...a.operations.captureSnapshot.available?Q(t,n):{},...J(t,n,a)}),[Symbol.asyncDispose]:async()=>void 0})},shutdown:async()=>void 0})}function J(e,t,n){let r={device:t.device,signal:t.scope.signal,resolveInteractor:e.localInteractors.resolve};return b({...r,facts:n.operations,pause:async n=>await e.clock.sleep(n,t.scope.signal)})}function Y(e){let t=e.kind===`device`?S:L,n=e.kind===`device`?S:R,r=v(e,C,{appLog:w,network:w,screenshot:B,snapshot:z,viewport:w,focus:E,gesture:O,scroll:k,typeText:D,touch:E,elementText:T,back:H,orientation:G,tvRemote:G,clipboard:W,systemButton:G,fold:G,triggerAppEvent:G,settings:G,readAlert:G,awaitAlert:G,acceptAlert:G,dismissAlert:G,keyboard:G,audioProbeCapture:K,audioProbeQuery:K,perf:G,readiness:w,lifecycle:a({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:P,clearRuntimeHints:P,closeApplication:n,finalizeApplicationClose:n,prepareAppleRunner:F,configureProviderPortReverse:I})});return Object.freeze({device:r.device,operations:{...r.operations,...c({capture:X(e,z),customActions:V,withoutActiveApp:X(e,z)}),...u({capture:X(e,B)}),...g({focus:X(e,E)}),...l({unsupported:O,plan:X(e,O),directionalFling:A,multiTouch:j,targetAuthoredDrag:M,viewport:N}),...d({scroll:X(e,k)}),...o({type:X(e,D)}),...Z(e),...s({readTextAtPoint:X(e,T)}),...h({back:X(e,H)}),...p({unsupported:G,home:X(e,U)}),...m({unsupported:W,read:X(e,W),write:X(e,W)})}})}function X(e,t){return e.kind===`device`?S:t}function Z(e){let t=e.kind===`device`?S:E;return _({unsupported:w,tap:t,longPress:t,fill:t})}function Q(e,t){let n=async n=>await e.snapshot.captureSurface(t.device,n.options,f(t.scope.signal,n));return Object.freeze({captureSnapshot:n,captureSnapshotWithCustomActions:n,captureSnapshotWithoutActiveApp:n})}export{q as createLinuxPlatformRuntime};
|