agent-device 0.21.7 → 0.21.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.7.apk → agent-device-android-ime-helper-0.21.9.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.9.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.7.manifest.json → agent-device-android-ime-helper-0.21.9.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.7.apk → agent-device-android-snapshot-helper-0.21.9.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.9.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.7.manifest.json → agent-device-android-snapshot-helper-0.21.9.manifest.json} +6 -6
- package/apple/macos-helper/Package.swift +16 -1
- package/apple/macos-helper/Sources/AgentDeviceMacOSDeviceHub/DeviceHubPose.swift +47 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSDeviceHub/DeviceHubWindowInventory.swift +65 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubPose.swift +225 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubSidebar.swift +57 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubWindowDiscovery.swift +108 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/main.swift +66 -13
- package/apple/macos-helper/Sources/AgentDeviceMacOSInput/MouseClickDelivery.swift +116 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSInput/MouseClickSchedule.swift +61 -0
- package/apple/macos-helper/Tests/AgentDeviceMacOSDeviceHubTests/DeviceHubPoseTests.swift +30 -0
- package/apple/macos-helper/Tests/AgentDeviceMacOSDeviceHubTests/DeviceHubWindowInventoryTests.swift +65 -0
- package/apple/macos-helper/Tests/AgentDeviceMacOSInputTests/MouseClickScheduleTests.swift +58 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h +1 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAppScreenCapture.swift +175 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +10 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +42 -15
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +8 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +45 -22
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +39 -734
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +20 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +63 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +13 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +25 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +5 -562
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotAcquisition.swift +566 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +5 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +594 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.h +35 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.m +160 -0
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +3 -0
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-frames.swift +203 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotCoordinateSpace.swift +5 -0
- package/dist/src/absence-observation-errors.js +1 -1
- package/dist/src/adapter.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-device-client.js +2 -2
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android-input-ownership.js +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/app-launch.js +1 -1
- package/dist/src/app-log-runtime2.js +3 -3
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/apple-runner-platform.js +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/artifact-paths.js +1 -0
- package/dist/src/back-mode.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +15 -11
- package/dist/src/cli.js +4 -4
- package/dist/src/client-types.d.ts +51 -1
- package/dist/src/command-tools.js +3 -3
- package/dist/src/config.js +1 -1
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-claim-rule.js +2 -2
- package/dist/src/device-input-state.d.ts +1 -1
- package/dist/src/device-rotation.js +1 -1
- package/dist/src/device-selection-resolver.js +1 -1
- package/dist/src/device-session.js +1 -1
- package/dist/src/device.js +1 -1
- package/dist/src/device2.js +1 -1
- package/dist/src/devicectl.js +1 -1
- package/dist/src/dispatch-resolve.js +1 -1
- package/dist/src/display-inventory.js +1 -1
- package/dist/src/doctor-facade.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/exec.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/fold-runtime.js +1 -0
- package/dist/src/gesture-admission.js +1 -1
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/harmonyos.js +1 -1
- package/dist/src/helper.js +2 -2
- package/dist/src/host.js +1 -0
- package/dist/src/interaction-positionals.js +1 -1
- package/dist/src/interaction-ref-policy.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor-operation-binding.js +1 -0
- package/dist/src/interactor-operation-catalog.js +1 -1
- package/dist/src/interactor.js +4 -5
- package/dist/src/interactor2.js +1 -1
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +2 -2
- package/dist/src/internal/png-worker.d.ts +5 -0
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/inventory2.js +1 -1
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/linux.js +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/location-coordinates.js +1 -1
- package/dist/src/macos-facade.js +1 -1
- package/dist/src/managed-device-scope.js +1 -1
- package/dist/src/mechanics.js +17 -16
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/mp4-duration.js +1 -0
- package/dist/src/multitouch-support.js +1 -1
- package/dist/src/owner-identity.js +1 -1
- package/dist/src/parameterized-recorded-fill.js +1 -1
- package/dist/src/perf-facade.js +2 -2
- package/dist/src/perf-runtime-plan.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-managed-owner.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +2 -2
- package/dist/src/platform-runtime-runtime-hints.js +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/png-crop-bytes.js +1 -1
- package/dist/src/png-encode.js +1 -0
- package/dist/src/png-size.js +1 -0
- package/dist/src/png-worker-client.js +1 -1
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/quality-warnings.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/recording-export-quality.js +1 -1
- package/dist/src/recording-scope.js +1 -0
- package/dist/src/recording.js +3 -0
- package/dist/src/registry.js +35 -35
- package/dist/src/replay.js +1 -1
- 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/runner-cache-metadata.js +2 -2
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-contract.js +3 -0
- package/dist/src/runner-dev-tools-security.js +1 -0
- package/dist/src/runner-device-readiness.js +1 -0
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-operations-facade.js +1 -1
- package/dist/src/runner-presentation.js +1 -1
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime.js +2 -2
- package/dist/src/runtime10.js +2 -1
- package/dist/src/runtime2.js +4 -4
- package/dist/src/runtime4.js +5 -5
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-admission-ledger.js +1 -1
- package/dist/src/screen-recording-resource-recovery.js +1 -1
- package/dist/src/screen-recording-transport.js +1 -1
- package/dist/src/screenshot-density.js +1 -1
- package/dist/src/screenshot-image.js +1 -0
- package/dist/src/screenshot-overlay-draw.js +1 -0
- package/dist/src/screenshot-runtime.js +1 -1
- 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 +7 -5
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-selectors.d.ts +58 -6
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/semantic-index.js +1 -1
- package/dist/src/session-routing.js +1 -1
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session-store.js +3 -3
- package/dist/src/session2.js +3 -3
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-boot.js +1 -1
- package/dist/src/simulator-facade.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot4.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src7.js +1 -1
- package/dist/src/src8.js +1 -1
- package/dist/src/stop-sequence.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/touch-runtime.js +1 -1
- package/dist/src/tree.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/video.js +2 -2
- package/dist/src/web2.js +1 -1
- package/package.json +3 -1
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.7.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.7.apk.sha256 +0 -1
- package/dist/src/png-transcode.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { k as Rect } from "./sdk-contracts.js";
|
|
2
|
-
import {
|
|
2
|
+
import { M as PointerTrajectory, N as PointerTrajectorySample, P as SinglePointerGesturePlan, j as MultiTouchGesturePlan } from "./sdk-selectors.js";
|
|
3
3
|
import { Readable, Stream, Writable } from "node:stream";
|
|
4
4
|
//#region packages/platform-android/src/helper-artifacts.d.ts
|
|
5
5
|
type AndroidImeHelperManifest = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";const t=[`portrait`,`portrait-upside-down`,`landscape-left`,`landscape-right`],n={portrait:0,"landscape-left":1,"portrait-upside-down":2,"landscape-right":3};function r(e){return n[e]*90}function i(e){return n[e]%2==0?`PORTRAIT`:`LANDSCAPE`}function a(t){if(t===void 0)throw new e(`INVALID_ARGS`,`orientation requires an orientation argument. Use portrait|portrait-upside-down|landscape-left|landscape-right.`);switch(t?.trim().toLowerCase()){case`portrait`:return`portrait`;case`portrait-upside-down`:case`upside-down`:return`portrait-upside-down`;case`landscape-left`:case`left`:return`landscape-left`;case`landscape-right`:case`right`:return`landscape-right`;default:throw new e(`INVALID_ARGS`,`Invalid rotation: ${t}. Use portrait|portrait-upside-down|landscape-left|landscape-right.`)}}export{a,
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";const t=[`portrait`,`portrait-upside-down`,`landscape-left`,`landscape-right`],n={portrait:0,"landscape-left":1,"portrait-upside-down":2,"landscape-right":3};function r(e){return n[e]*90}function i(e){return n[e]%2==0?`PORTRAIT`:`LANDSCAPE`}function a(t){if(t===void 0)throw new e(`INVALID_ARGS`,`orientation requires an orientation argument. Use portrait|portrait-upside-down|landscape-left|landscape-right.`);switch(t?.trim().toLowerCase()){case`portrait`:return`portrait`;case`portrait-upside-down`:case`upside-down`:return`portrait-upside-down`;case`landscape-left`:case`left`:return`landscape-left`;case`landscape-right`:case`right`:return`landscape-right`;default:throw new e(`INVALID_ARGS`,`Invalid rotation: ${t}. Use portrait|portrait-upside-down|landscape-left|landscape-right.`)}}const o=[`closed`,`half-open`,`open`],s=`closed|half-open|open`;function c(e){if(Number.isFinite(e))return e<=l?`closed`:e>=u?`open`:`half-open`}const l=1,u=179;function d(t){if(t===void 0)throw new e(`INVALID_ARGS`,`fold requires a pose argument. Use ${s}.`);switch(t.trim().toLowerCase()){case`closed`:case`close`:case`fold`:case`folded`:return`closed`;case`half-open`:case`half`:case`half-unfolded`:case`partially-open`:case`book`:return`half-open`;case`open`:case`unfold`:case`unfolded`:case`fully-open`:case`flat`:return`open`;default:throw new e(`INVALID_ARGS`,`Invalid fold pose: ${t}. Use ${s}.`)}}export{i as a,a as c,s as i,d as l,n,r as o,o as r,c as s,t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import{C as n,d as r,g as i,s as a,v as o}from"./sdk-device.js";var s=e({markSelectionBootOccurred:()=>u,resolveExistingSessionDeviceSelection:()=>l,resolveInventoryDeviceSelection:()=>c});async function c(e){let{devices:t,selector:r,source:i}=e,s=a(r);if(i===`provider`&&!s)return p(t,r);if(i===`local`&&!s){let n=await m(t,r,e.appleSimulatorAppTarget);if(n)return n}let c=t.filter(e=>o(e,r,{includeExplicitSelectors:s}));try{return d(await n([...t],r),c,{explicitSelector:s,source:i})}catch(e){throw h(e,c)}}function l(e){return{device:e,reason:`existing-session`,source:`session`,candidateCount:1,bootOccurred:!1}}function u(e){if(!e||e.source!==`local`)return e;let{device:t}=e;return t.booted!==!0&&(t.kind===`simulator`||t.kind===`emulator`)?{...e,bootOccurred:!0}:e}function d(e,t,n){return{device:e,reason:n.explicitSelector?`explicit-selector`:n.source===`provider`?`single-provider-device`:f(e,t),source:n.source,candidateCount:t.length,bootOccurred:!1}}function f(e,t){return e.booted===!0&&t.filter(e=>e.booted===!0).length===1?`single-booted-local`:!e.booted&&t.length===1?`single-bootable-local`:`preferred-local`}async function p(e,r){let i=e.filter(e=>o(e,r)),a=i[0];if(a!==void 0&&i.length===1)return d(a,i,{explicitSelector:!1,source:`provider`});try{await n([...e],r)}catch(e){throw h(e,i)}throw new t(`AMBIGUOUS_MATCH`,`Multiple provider devices match this request.`,{...g(i),matches:i.length,hint:`Select the leased provider device explicitly with --device, --udid, or --serial.`,retrySelectors:_(i)})}async function m(e,n,i){let a=i?.trim();if(!a)return;let{readInstalledAppProbe:s}=await import(`./device-inventory-context.js`).then(e=>e.t),c=s();if(!c)return;let l=e.filter(e=>o(e,n)&&r(e)&&e.kind===`simulator`&&e.booted===!0);if(l.length<2)return;let u=(await Promise.all(l.map(async e=>await c(e,a)?e:void 0))).filter(e=>e!==void 0),d=u[0];if(d!==void 0&&u.length===1)return{device:d,reason:`single-app-installed-local`,source:`local`,candidateCount:1,bootOccurred:!1};throw u.length===0?new t(`APP_NOT_INSTALLED`,`No booted iOS simulator has ${a} installed`,{appTarget:a,...g(l),hint:`Install the app on a booted simulator, or pass --udid to select the intended device explicitly.`,retrySelectors:_(l)}):new t(`AMBIGUOUS_MATCH`,`Multiple booted iOS simulators have ${a} installed`,{appTarget:a,...g(u),hint:`Pass --udid to select the intended simulator explicitly.`,retrySelectors:_(u)})}function h(e,n){return!(e instanceof t)||e.code!==`AMBIGUOUS_MATCH`?e:new t(e.code,e.message,{...e.details??{},...g(n),retrySelectors:_(n)},e)}function g(e){return{devices:e.slice(0,10).map(e=>({id:e.id,name:e.name}))}}function _(e){return e.slice(0,10).flatMap(e=>[{flag:i(e.platform)?`--serial`:`--udid`,value:e.id},{flag:`--device`,value:e.name}])}export{u as n,l as r,s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";import{r as t}from"./sdk-batch-runner.js";import{n}from"./app-inventory.js";import"./device.js";import{t as r}from"./request-cancellation.js";import{n as i,t as a}from"./ios-client.js";import{i as o}from"./snapshot.js";import s from"node:path";import c from"node:fs";import l from"node:os";import{setTimeout as u}from"node:timers/promises";function d(e){return e?.trim()||void 0}async function f(e,t){let n=await i({apiUrl:e.apiUrl,adbUrl:e.adbUrl,token:e.token,logLevel:`warn`}),r={platform:`android`,lease:e.lease,instanceId:e.instanceId,device:e.device,client:n,token:e.token,dependencies:t},a={exec:async(e,t)=>await v(r,e,t),text:async e=>{await n.setText(e.target,e.text)}};return a.reverse=await t.android.createPortReverse(a.exec),Object.assign(r,{adbProvider:a})}function p(e){return e.dependencies.android.createInteractor(e.device,e.adbProvider)}async function m(e,t,n,i,a,o){a?.throwIfAborted();let s=d(i?.packageNameHint);i?.relaunch&&s&&await t.dependencies.android.forceStopApp(async(e,n)=>await v(t,e,n),s,a);let c=await r(o,e.assets.getOrUpload({path:n,name:w(s,n)},{signal:a}),a);await r(o,t.client.sendAsset(c.signedDownloadUrl),a),a?.throwIfAborted();let l=s?await t.dependencies.android.inferAppName(s):void 0;return{...s?{packageName:s,launchTarget:s}:{},...l?{appName:l}:{}}}async function h(e,t){await e.adbProvider.reverse?.ensure({local:C(t.devicePort),remote:C(t.hostPort),ownerId:t.name})}async function g(e){await e.adbTunnelPromise?.catch(()=>{});let t=e.adbSerial;t&&(await _(e),await e.dependencies.host.runAdb(e.dependencies.android.hostAdbInvocation([`disconnect`,t]),{allowFailure:!0,timeoutMs:1e4}).catch(()=>{})),e.adbTunnel?.close(),e.adbTunnel=void 0,e.adbSerial=void 0,e.adbTunnelPromise=void 0}async function _(e){let t=e.adbProvider.reverse;if(!t?.list)return;let n=await t.list().catch(()=>[]),r=new Set,i=[];for(let e of n)e.ownerId?r.add(e.ownerId):i.push(e.local);await Promise.allSettled([...[...r].map(async e=>await t.removeAllOwned(e)),...i.map(async e=>await t.remove(e))])}async function v(e,t,n){let{invocation:r,result:i}=await y(e,t,n);return await b(r,i,n?.allowFailure,e.dependencies)}async function y(e,t,n){let r=await x(e),i=e.dependencies.android.deviceAdbInvocation(r,t);return{invocation:i,result:await e.dependencies.host.runAdb(i,{allowFailure:n?.allowFailure,binaryStdout:n?.binaryStdout,stdin:n?.stdin,timeoutMs:n?.timeoutMs??3e4,signal:n?.signal})}}async function b(e,t,n,r){if(t.exitCode!==0&&n!==!0)throw await r.android.adbError(`Limrun Android ADB command failed`,t,e);return t}async function x(e){if(e.adbSerial)return e.adbSerial;let t=e.adbTunnelPromise??S(e);e.adbTunnelPromise=t;try{return await t}catch(n){throw e.adbTunnelPromise===t&&(e.adbTunnelPromise=void 0),n}}async function S(e){let t=await e.client.startAdbTunnel(),n=`${t.address.address}:${t.address.port}`;return e.adbTunnel=t,e.adbSerial=n,n}function C(t){if(!Number.isInteger(t)||t<1||t>65535)throw new e(`INVALID_ARGS`,`Invalid Android tcp reverse port: ${t}`);return`tcp:${t}`}function w(e,t){let n=s.extname(t)||`.apk`;return`${e?.replaceAll(/[^a-zA-Z0-9_.-]+/g,`-`)||`android-app`}${n}`}async function T(e,t){let n=await a({apiUrl:e.apiUrl,token:e.token,logLevel:`warn`});return{platform:`ios`,lease:e.lease,instanceId:e.instanceId,device:e.device,client:n,token:e.token,dependencies:t}}async function E(e,t,n,i,a,o){a?.throwIfAborted();let s=await A(n,t.dependencies);try{a?.throwIfAborted();let n=await r(o,e.assets.getOrUpload({path:s.uploadPath,name:s.assetName},{signal:a}),a),c=(await D(t,n.signedDownloadUrl,{md5:n.md5,relaunch:i?.relaunch,appIdentifierHint:i?.appIdentifierHint},a,o)).appId;return{...c?{bundleId:c,launchTarget:c}:{},...s.appName?{appName:s.appName}:{}}}finally{await s.cleanup()}}async function D(t,n,i,a,o){a?.throwIfAborted();let s=await r(o,t.client.listApps(),a).catch(e=>{if(a?.aborted)throw e}),c=d((await r(o,t.client.installApp(n,{md5:i?.md5,launchMode:i?.relaunch?`RelaunchIfRunning`:`ForegroundIfRunning`}),a)).bundleId),l=d(i?.appIdentifierHint),f=[];for(let e of M){e>0&&await u(e,void 0,{signal:a}),f=await r(o,t.client.listApps(),a);let n=F({resultBundleId:c,requestedBundleId:l,beforeInstallApps:s,afterInstallApps:f});if(n)return{appId:n}}throw new e(`COMMAND_FAILED`,`Limrun iOS app installation could not be verified.`,{resultBundleId:c,requestedBundleId:l,installedUserApps:f.filter(L).map(e=>e.bundleId).sort()})}function O(e){return new k(e)}var k=class{session;constructor(e){this.session=e}async open(e,n){if(n?.url){await this.session.client.launchApp(await this.session.dependencies.ios.resolveAppAlias(e)),await this.session.client.openUrl(n.url);return}if(t(e)){await this.session.client.openUrl(e);return}await this.session.client.launchApp(await this.session.dependencies.ios.resolveAppAlias(e))}async openDevice(){}async close(e){e&&await this.session.client.terminateApp(await this.session.dependencies.ios.resolveAppAlias(e)).catch(()=>{})}async tap(e,t){await this.session.client.tap(e,t)}async tapElementSelector(e){await this.session.client.tapElement(o(e))}async doubleTap(e,t){await this.session.client.performActions([{type:`tap`,x:e,y:t},{type:`wait`,durationMs:P},{type:`tap`,x:e,y:t}])}async longPress(e,t,n=N){await this.session.client.performActions([{type:`touchDown`,x:e,y:t},{type:`wait`,durationMs:n},{type:`touchUp`,x:e,y:t}])}async focus(e,t){await this.tap(e,t)}async type(e,t){await this.enterText(e,t)}async fill(e,t,n,r){let{awaitLimrunTextEntryFocus:i,readLimrunUnambiguousTapTargets:a,readLimrunTextEntryFocus:o}=await import(`./text-entry-focus.js`),s=a(await this.session.client.elementTree(),e,t);await this.tap(e,t);let c=await i({targetsAtPoint:s,readFocus:async()=>o(await this.session.client.elementTree()),sleep:e=>u(e),x:e,y:t});return await this.session.client.pressKey(`a`,[`command`]),n.length===0?(await this.session.client.pressKey(`delete`),{textEntryReadiness:c}):(await this.enterText(n,r),{textEntryReadiness:c})}async enterText(e,t){if(t&&t>0){for(let n of Array.from(e))await this.session.client.typeText(n,!1,{requireFocus:!1}),await u(t);return}await this.session.client.typeText(e,!1,{requireFocus:!1})}async scroll(e,t){await this.session.client.scroll(e,t?.pixels??300)}async screenshot(e){let{transcodeScreenshotToPngAsync:t}=await import(`./png-worker-client.js`).then(e=>e.o),n=await this.session.client.screenshot(),r=await t(Buffer.from(n.base64,`base64`),`Limrun iOS screenshot`);c.mkdirSync(s.dirname(e),{recursive:!0}),await c.promises.writeFile(e,r)}async snapshot(){let{captureLimrunIosSnapshot:e}=await import(`./ios-snapshot-adapter.js`);return await e(this.session)}async back(){await this.session.client.pressKey(`escape`)}async home(){throw z(`home`,`Limrun iOS direct sessions do not expose home yet.`)}async setOrientation(e){if(e===`portrait-upside-down`)throw z(`orientation`,`Limrun iOS direct sessions support portrait and landscape orientation, not portrait upside-down.`);await this.session.client.setOrientation(e===`portrait`?`Portrait`:`Landscape`)}async performGesture(){throw z(`gesture`,`Limrun iOS direct sessions do not expose portable gesture execution yet.`)}async appSwitcher(){throw z(`app-switcher`,`Limrun iOS direct sessions do not expose app switcher yet.`)}async actionButton(){throw z(`action-button`,`Limrun iOS direct sessions do not expose the Action Button.`)}async tvRemote(){throw z(`tv-remote`,`Limrun iOS direct sessions do not expose tv remote control.`)}async readAlert(){throw z(`alert`,R)}async awaitAlert(){throw z(`alert`,R)}async acceptAlert(){throw z(`alert`,R)}async dismissAlert(){throw z(`alert`,R)}async readClipboard(){throw z(`clipboard`,`Limrun iOS direct sessions do not expose clipboard read yet.`)}async writeClipboard(){throw z(`clipboard`,`Limrun iOS direct sessions do not expose clipboard write yet.`)}async setSetting(){throw z(`settings`,`Limrun iOS direct sessions do not expose settings changes yet.`)}};async function A(e,t){if(!(await c.promises.stat(e)).isDirectory())return{uploadPath:e,assetName:s.basename(e),appName:j(e),cleanup:async()=>{}};let n=await c.promises.mkdtemp(s.join(l.tmpdir(),`agent-device-limrun-ios-app-`)),r=s.join(n,`${s.basename(e)}.zip`);try{await t.host.archiveDirectory({sourceDirectory:s.dirname(e),entryName:s.basename(e),archivePath:r})}catch(e){throw await c.promises.rm(n,{recursive:!0,force:!0}),e}return{uploadPath:r,assetName:s.basename(r),appName:await t.ios.readBundleAppName(e)??j(e),cleanup:async()=>{await c.promises.rm(n,{recursive:!0,force:!0})}}}function j(e){return s.basename(e).replace(/\.(?:app|ipa|apk|aab|zip)$/i,``)||void 0}const M=[0,250],N=800,P=80;function F(e){let t=new Set(e.afterInstallApps.map(e=>e.bundleId));return(e.resultBundleId&&t.has(e.resultBundleId)?e.resultBundleId:void 0)??(e.requestedBundleId&&t.has(e.requestedBundleId)?e.requestedBundleId:void 0)??I(e.beforeInstallApps,e.afterInstallApps)}function I(e,t){if(!e)return;let n=new Set(e.map(e=>e.bundleId)),r=t.filter(e=>L(e)&&!n.has(e.bundleId));return r.length===1?r[0]?.bundleId:void 0}function L(e){return!e.bundleId.startsWith(`com.apple.`)&&!e.installType.toLowerCase().includes(`system`)}const R=`Limrun iOS direct sessions do not expose alert inspection yet.`;function z(t,n){throw new e(`UNSUPPORTED_OPERATION`,n,{command:t})}function B(e){return e.platform===`android`?V(e):H(e)}function V(e){let t=e.adbProvider.exec;return{platform:`android`,device:e.device,interactor:p(e),adb:e.adbProvider,listApps:async r=>await e.dependencies.android.listApps(t,n(r)),getForegroundApp:async n=>await e.dependencies.android.getForegroundApp(e.device,t,n),pressKey:async(t,n)=>{await e.client.pressKey(t,n)},getKeyboardState:async()=>await e.dependencies.android.getKeyboardState(t),dismissKeyboard:async()=>await e.dependencies.android.dismissKeyboard(t),readLogs:async n=>await e.dependencies.android.readLogs(t,n),...U(e.client,e.token,e.dependencies.host),installRemoteApp:async t=>{await e.client.sendAsset(t)}}}function H(e){return{platform:`ios`,device:e.device,interactor:O(e),viewport:{width:e.client.deviceInfo.screenWidth,height:e.client.deviceInfo.screenHeight},listApps:async t=>(await e.client.listApps()).filter(e=>n(t)===`all`||L(e)).map(e=>({id:e.bundleId,name:e.name,installType:e.installType})).sort((e,t)=>e.id.localeCompare(t.id)),pressKey:async(t,n)=>{await e.client.pressKey(t,n)},readLogs:async(t,n)=>await e.client.appLogTail(t,n),...U(e.client,e.token,e.dependencies.host),installRemoteApp:async(t,n)=>await D(e,t,n),runSimctl:t=>e.client.simctl(t)}}function U(e,t,n){return{startRecording:async t=>{await e.startRecording(t)},stopRecording:async()=>({downloadUrl:await e.stopRecording({})}),downloadRecording:async e=>{await n.downloadFile({url:e.downloadUrl,headers:{Authorization:`Bearer ${t}`},destinationPath:e.outPath,timeoutMs:6e4})}}}export{g as a,f as c,E as i,m as l,O as n,h as o,T as r,p as s,B as t};
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{r as t}from"./sdk-batch-runner.js";import{n}from"./app-inventory.js";import"./device.js";import{t as r}from"./request-cancellation.js";import{n as i,t as a}from"./ios-client.js";import{i as o}from"./snapshot.js";import s from"node:path";import c from"node:fs";import l from"node:os";import{setTimeout as u}from"node:timers/promises";function d(e){return e?.trim()||void 0}async function f(e,t){let n=await i({apiUrl:e.apiUrl,adbUrl:e.adbUrl,token:e.token,logLevel:`warn`}),r={platform:`android`,lease:e.lease,instanceId:e.instanceId,device:e.device,client:n,token:e.token,dependencies:t},a={exec:async(e,t)=>await v(r,e,t),text:async e=>{await n.setText(e.target,e.text)}};return a.reverse=await t.android.createPortReverse(a.exec),Object.assign(r,{adbProvider:a})}function p(e){return e.dependencies.android.createInteractor(e.device,e.adbProvider)}async function m(e,t,n,i,a,o){a?.throwIfAborted();let s=d(i?.packageNameHint);i?.relaunch&&s&&await t.dependencies.android.forceStopApp(async(e,n)=>await v(t,e,n),s,a);let c=await r(o,e.assets.getOrUpload({path:n,name:w(s,n)},{signal:a}),a);await r(o,t.client.sendAsset(c.signedDownloadUrl),a),a?.throwIfAborted();let l=s?await t.dependencies.android.inferAppName(s):void 0;return{...s?{packageName:s,launchTarget:s}:{},...l?{appName:l}:{}}}async function h(e,t){await e.adbProvider.reverse?.ensure({local:C(t.devicePort),remote:C(t.hostPort),ownerId:t.name})}async function g(e){await e.adbTunnelPromise?.catch(()=>{});let t=e.adbSerial;t&&(await _(e),await e.dependencies.host.runAdb(e.dependencies.android.hostAdbInvocation([`disconnect`,t]),{allowFailure:!0,timeoutMs:1e4}).catch(()=>{})),e.adbTunnel?.close(),e.adbTunnel=void 0,e.adbSerial=void 0,e.adbTunnelPromise=void 0}async function _(e){let t=e.adbProvider.reverse;if(!t?.list)return;let n=await t.list().catch(()=>[]),r=new Set,i=[];for(let e of n)e.ownerId?r.add(e.ownerId):i.push(e.local);await Promise.allSettled([...[...r].map(async e=>await t.removeAllOwned(e)),...i.map(async e=>await t.remove(e))])}async function v(e,t,n){let{invocation:r,result:i}=await y(e,t,n);return await b(r,i,n?.allowFailure,e.dependencies)}async function y(e,t,n){let r=await x(e),i=e.dependencies.android.deviceAdbInvocation(r,t);return{invocation:i,result:await e.dependencies.host.runAdb(i,{allowFailure:n?.allowFailure,binaryStdout:n?.binaryStdout,stdin:n?.stdin,timeoutMs:n?.timeoutMs??3e4,signal:n?.signal})}}async function b(e,t,n,r){if(t.exitCode!==0&&n!==!0)throw await r.android.adbError(`Limrun Android ADB command failed`,t,e);return t}async function x(e){if(e.adbSerial)return e.adbSerial;let t=e.adbTunnelPromise??S(e);e.adbTunnelPromise=t;try{return await t}catch(n){throw e.adbTunnelPromise===t&&(e.adbTunnelPromise=void 0),n}}async function S(e){let t=await e.client.startAdbTunnel(),n=`${t.address.address}:${t.address.port}`;return e.adbTunnel=t,e.adbSerial=n,n}function C(t){if(!Number.isInteger(t)||t<1||t>65535)throw new e(`INVALID_ARGS`,`Invalid Android tcp reverse port: ${t}`);return`tcp:${t}`}function w(e,t){let n=s.extname(t)||`.apk`;return`${e?.replaceAll(/[^a-zA-Z0-9_.-]+/g,`-`)||`android-app`}${n}`}async function T(e,t){let n=await a({apiUrl:e.apiUrl,token:e.token,logLevel:`warn`});return{platform:`ios`,lease:e.lease,instanceId:e.instanceId,device:e.device,client:n,token:e.token,dependencies:t}}async function E(e,t,n,i,a,o){a?.throwIfAborted();let s=await A(n,t.dependencies);try{a?.throwIfAborted();let n=await r(o,e.assets.getOrUpload({path:s.uploadPath,name:s.assetName},{signal:a}),a),c=(await D(t,n.signedDownloadUrl,{md5:n.md5,relaunch:i?.relaunch,appIdentifierHint:i?.appIdentifierHint},a,o)).appId;return{...c?{bundleId:c,launchTarget:c}:{},...s.appName?{appName:s.appName}:{}}}finally{await s.cleanup()}}async function D(t,n,i,a,o){a?.throwIfAborted();let s=await r(o,t.client.listApps(),a).catch(e=>{if(a?.aborted)throw e}),c=d((await r(o,t.client.installApp(n,{md5:i?.md5,launchMode:i?.relaunch?`RelaunchIfRunning`:`ForegroundIfRunning`}),a)).bundleId),l=d(i?.appIdentifierHint),f=[];for(let e of M){e>0&&await u(e,void 0,{signal:a}),f=await r(o,t.client.listApps(),a);let n=F({resultBundleId:c,requestedBundleId:l,beforeInstallApps:s,afterInstallApps:f});if(n)return{appId:n}}throw new e(`COMMAND_FAILED`,`Limrun iOS app installation could not be verified.`,{resultBundleId:c,requestedBundleId:l,installedUserApps:f.filter(L).map(e=>e.bundleId).sort()})}function O(e){return new k(e)}var k=class{session;constructor(e){this.session=e}async open(e,n){if(n?.url){await this.session.client.launchApp(await this.session.dependencies.ios.resolveAppAlias(e)),await this.session.client.openUrl(n.url);return}if(t(e)){await this.session.client.openUrl(e);return}await this.session.client.launchApp(await this.session.dependencies.ios.resolveAppAlias(e))}async openDevice(){}async close(e){e&&await this.session.client.terminateApp(await this.session.dependencies.ios.resolveAppAlias(e)).catch(()=>{})}async tap(e,t){await this.session.client.tap(e,t)}async tapElementSelector(e){await this.session.client.tapElement(o(e))}async doubleTap(e,t){await this.session.client.performActions([{type:`tap`,x:e,y:t},{type:`wait`,durationMs:P},{type:`tap`,x:e,y:t}])}async longPress(e,t,n=N){await this.session.client.performActions([{type:`touchDown`,x:e,y:t},{type:`wait`,durationMs:n},{type:`touchUp`,x:e,y:t}])}async focus(e,t){await this.tap(e,t)}async type(e,t){await this.enterText(e,t)}async fill(e,t,n,r){let{awaitLimrunTextEntryFocus:i,readLimrunUnambiguousTapTargets:a,readLimrunTextEntryFocus:o}=await import(`./text-entry-focus.js`),s=a(await this.session.client.elementTree(),e,t);await this.tap(e,t);let c=await i({targetsAtPoint:s,readFocus:async()=>o(await this.session.client.elementTree()),sleep:e=>u(e),x:e,y:t});return await this.session.client.pressKey(`a`,[`command`]),n.length===0?(await this.session.client.pressKey(`delete`),{textEntryReadiness:c}):(await this.enterText(n,r),{textEntryReadiness:c})}async enterText(e,t){if(t&&t>0){for(let n of Array.from(e))await this.session.client.typeText(n,!1,{requireFocus:!1}),await u(t);return}await this.session.client.typeText(e,!1,{requireFocus:!1})}async scroll(e,t){await this.session.client.scroll(e,t?.pixels??300)}async screenshot(e){let{transcodeScreenshotToPngAsync:t}=await import(`./png-worker-client.js`).then(e=>e.s),n=await this.session.client.screenshot(),r=await t(Buffer.from(n.base64,`base64`),`Limrun iOS screenshot`);c.mkdirSync(s.dirname(e),{recursive:!0}),await c.promises.writeFile(e,r)}async snapshot(){let{captureLimrunIosSnapshot:e}=await import(`./ios-snapshot-adapter.js`);return await e(this.session)}async back(){await this.session.client.pressKey(`escape`)}async home(){throw z(`home`,`Limrun iOS direct sessions do not expose home yet.`)}async setOrientation(e){if(e===`portrait-upside-down`)throw z(`orientation`,`Limrun iOS direct sessions support portrait and landscape orientation, not portrait upside-down.`);await this.session.client.setOrientation(e===`portrait`?`Portrait`:`Landscape`)}async performGesture(){throw z(`gesture`,`Limrun iOS direct sessions do not expose portable gesture execution yet.`)}async appSwitcher(){throw z(`app-switcher`,`Limrun iOS direct sessions do not expose app switcher yet.`)}async tvRemote(){throw z(`tv-remote`,`Limrun iOS direct sessions do not expose tv remote control.`)}async readAlert(){throw z(`alert`,R)}async awaitAlert(){throw z(`alert`,R)}async acceptAlert(){throw z(`alert`,R)}async dismissAlert(){throw z(`alert`,R)}async readClipboard(){throw z(`clipboard`,`Limrun iOS direct sessions do not expose clipboard read yet.`)}async writeClipboard(){throw z(`clipboard`,`Limrun iOS direct sessions do not expose clipboard write yet.`)}async setSetting(){throw z(`settings`,`Limrun iOS direct sessions do not expose settings changes yet.`)}};async function A(e,t){if(!(await c.promises.stat(e)).isDirectory())return{uploadPath:e,assetName:s.basename(e),appName:j(e),cleanup:async()=>{}};let n=await c.promises.mkdtemp(s.join(l.tmpdir(),`agent-device-limrun-ios-app-`)),r=s.join(n,`${s.basename(e)}.zip`);try{await t.host.archiveDirectory({sourceDirectory:s.dirname(e),entryName:s.basename(e),archivePath:r})}catch(e){throw await c.promises.rm(n,{recursive:!0,force:!0}),e}return{uploadPath:r,assetName:s.basename(r),appName:await t.ios.readBundleAppName(e)??j(e),cleanup:async()=>{await c.promises.rm(n,{recursive:!0,force:!0})}}}function j(e){return s.basename(e).replace(/\.(?:app|ipa|apk|aab|zip)$/i,``)||void 0}const M=[0,250],N=800,P=80;function F(e){let t=new Set(e.afterInstallApps.map(e=>e.bundleId));return(e.resultBundleId&&t.has(e.resultBundleId)?e.resultBundleId:void 0)??(e.requestedBundleId&&t.has(e.requestedBundleId)?e.requestedBundleId:void 0)??I(e.beforeInstallApps,e.afterInstallApps)}function I(e,t){if(!e)return;let n=new Set(e.map(e=>e.bundleId)),r=t.filter(e=>L(e)&&!n.has(e.bundleId));return r.length===1?r[0]?.bundleId:void 0}function L(e){return!e.bundleId.startsWith(`com.apple.`)&&!e.installType.toLowerCase().includes(`system`)}const R=`Limrun iOS direct sessions do not expose alert inspection yet.`;function z(t,n){throw new e(`UNSUPPORTED_OPERATION`,n,{command:t})}function B(e){return e.platform===`android`?V(e):H(e)}function V(e){let t=e.adbProvider.exec;return{platform:`android`,device:e.device,interactor:p(e),adb:e.adbProvider,listApps:async r=>await e.dependencies.android.listApps(t,n(r)),getForegroundApp:async n=>await e.dependencies.android.getForegroundApp(e.device,t,n),pressKey:async(t,n)=>{await e.client.pressKey(t,n)},getKeyboardState:async()=>await e.dependencies.android.getKeyboardState(t),dismissKeyboard:async()=>await e.dependencies.android.dismissKeyboard(t),readLogs:async n=>await e.dependencies.android.readLogs(t,n),...U(e.client,e.token,e.dependencies.host),installRemoteApp:async t=>{await e.client.sendAsset(t)}}}function H(e){return{platform:`ios`,device:e.device,interactor:O(e),viewport:{width:e.client.deviceInfo.screenWidth,height:e.client.deviceInfo.screenHeight},listApps:async t=>(await e.client.listApps()).filter(e=>n(t)===`all`||L(e)).map(e=>({id:e.bundleId,name:e.name,installType:e.installType})).sort((e,t)=>e.id.localeCompare(t.id)),pressKey:async(t,n)=>{await e.client.pressKey(t,n)},readLogs:async(t,n)=>await e.client.appLogTail(t,n),...U(e.client,e.token,e.dependencies.host),installRemoteApp:async(t,n)=>await D(e,t,n),runSimctl:t=>e.client.simctl(t)}}function U(e,t,n){return{startRecording:async t=>{await e.startRecording(t)},stopRecording:async()=>({downloadUrl:await e.stopRecording({})}),downloadRecording:async e=>{await n.downloadFile({url:e.downloadUrl,headers:{Authorization:`Bearer ${t}`},destinationPath:e.outPath,timeoutMs:6e4})}}}export{g as a,f as c,E as i,m as l,O as n,h as o,T as r,p as s,B as t};
|
package/dist/src/device.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,
|
|
1
|
+
import{d as e,f as t,y as n}from"./sdk-device.js";const r=[`android`,`harmonyos`,`apple`,`vega`,`linux`];function i(e){let{booted:t,kind:n,...r}=e;return r}const a={platform:`web`,id:`agent-browser-chrome`,name:`Agent Browser Chrome`,kind:`device`,target:`desktop`,booted:!0};function o(e){let t=c();for(let n of e){let e=l(n);t[e].available+=1,n.booted===!0&&(t[e].booted+=1)}return t}function s(e,t){return e.filter(e=>n(e,t.platform)&&(t.target===void 0||(e.target??`mobile`)===t.target)&&(t.kind===void 0||e.kind===t.kind)&&(t.booted===void 0||e.booted===t.booted))}function c(){return{android:{available:0,booted:0},harmonyos:{available:0,booted:0},apple:{available:0,booted:0},vega:{available:0,booted:0},linux:{available:0,booted:0},web:{available:0,booted:0}}}function l(n){return e(n)||t(n)?`apple`:n.platform}const u=new Set([`DEVICE_CLAIM_LIVE_OWNER`,`DEVICE_CLAIM_RECOVERY_PENDING`,`DEVICE_CLAIM_OWNER_UNCERTAIN`]);function d(e){return u.has(e)}export{d as a,s as i,a as n,i as o,o as r,r as t};
|
package/dist/src/device2.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";import{
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{b as t}from"./sdk-device.js";import{s as n}from"./device-shell.js";import{i as r,n as i,t as a}from"./device-claim-inspection.js";import{t as o}from"./shared.js";const s=async({positionals:t,flags:n})=>{if(t.length!==1||t[0]!==`status`&&t[0]!==`release`)throw new e(`INVALID_ARGS`,`device accepts only: status, release`);if(t[0]===`release`)return await c(n);let s=r({platform:n.platform,device:n.device,udid:n.udid,serial:n.serial}),l=s.filter(e=>i(e.classification)),u=(n.stale?l:s.filter(e=>!i(e.classification))).map(m),d={claims:u,...n.stale?{}:{hiddenStaleClaims:l.length}};return await o(n,d,()=>g(u,{staleOnly:n.stale===!0,hiddenStaleClaims:l.length,staleCommand:x(n,`status`),releasableClaims:l.filter(e=>a(e.classification)).length,releaseCommand:x(n,`release`)})),!0};async function c(t){if(t.stale!==!0)throw new e(`INVALID_ARGS`,`device release only releases provably stale claims; pass --stale to confirm.`,{hint:`A live owner is released by closing its session from its own workspace, or by stopping its daemon: agent-device daemon stop --state-dir <owner state dir>.`});let{runStaleDeviceClaimRelease:n}=await import(`./device-release.js`),r=await n({platform:t.platform,device:t.device,udid:t.udid,serial:t.serial}),i={released:r.filter(e=>e.status===`released`).map(l),retained:r.filter(e=>e.status===`retained`).map(l),refused:r.filter(e=>e.status===`refused`).map(l),changed:r.filter(e=>e.status===`changed`).map(l)};return await o(t,i,()=>u(r)),!0}function l(e){let{device:t,...n}=e;return{...n,...t?{device:h(t)}:{}}}function u(e){return e.length===0?`No local device claims matched.`:e.map(d).join(`
|
|
2
2
|
`)}function d(e){let n=e.device?`${t({platform:e.device.family,appleOs:e.device.appleOs})} ${e.device.name}`:e.deviceKey??e.fileName,r=f(e);switch(e.status){case`released`:return`released ${n}${r}`;case`retained`:return`retained ${n}${r} — resources not settled (${e.reason}); the claim stays until they are.`;case`refused`:return`refused ${n}${r} — ${e.reason} (${e.classification}); ${p(e)}`;case`changed`:return`changed ${n} — the claim changed while releasing; re-run device status.`}}function f(e){return e.allocator?` allocator=${e.allocator.instanceId} incarnation=${e.allocator.identityIncarnationId}`:e.session?` session=${e.session} workspace=${e.workspace}`:``}function p(e){return e.classification===`allocator-held`?`held by its managed-device allocator; it is cleared only after the allocator proves the identity removed.`:e.classification===`live`||e.classification===`owner-state-dir-gone`?e.stateDir?`close the owning session from its workspace, or stop its daemon: agent-device daemon stop --state-dir ${n(e.stateDir)}`:`close the owning session from its workspace first.`:`only provably dead owners are released; nothing was changed.`}function m(e){let t=e.claim??e.allocatorClaim;return{...e.deviceKey?{deviceKey:e.deviceKey}:{},...t?{}:{fileName:e.fileName},classification:e.classification,...t?{device:h(t.device)}:{},...e.claim?{owner:{session:e.claim.session,workspace:e.claim.workspace,stateDir:e.claim.stateDir,pid:e.claim.ownerPid,startTime:e.claim.ownerStartTime}}:{},...e.allocatorClaim?{owner:{kind:`allocator`,stateDir:e.allocatorClaim.stateDir,allocator:e.allocatorClaim.allocator}}:{},...e.error?{error:e.error}:{}}}function h(e){let{family:n,...r}=e;return{...r,platform:t({platform:n,appleOs:e.appleOs})}}function g(e,t){let n=e.map(v);if(n.length===0){if(t.staleOnly)return`No stale local device claims found.`;if(t.hiddenStaleClaims===0)return`No local device claims found.`}return[...n.length===0?[`No live local device claims found.`]:n,..._(t)].join(`
|
|
3
3
|
`)}function _(e){if(e.staleOnly)return e.releasableClaims>0?[`Release provably dead owners with: ${e.releaseCommand}`]:[];if(e.hiddenStaleClaims===0)return[];let t=e.hiddenStaleClaims===1?`claim`:`claims`;return[`${e.hiddenStaleClaims} stale ${t} hidden; inspect with: ${e.staleCommand}`]}function v(e){return`${y(e)}: ${e.classification}${b(e.owner)}`}function y(e){let t=e.device;return t?`${t.platform??`unknown`} ${t.name??t.id??`claim`}`:String(e.deviceKey??e.fileName??`claim`)}function b(e){if(!e||typeof e!=`object`)return``;let t=e;return t.allocator?` allocator=${t.allocator.instanceId} incarnation=${t.allocator.identityIncarnationId} installation=${t.stateDir}`:` session=${t.session} workspace=${t.workspace}`}function x(e,t){let r=[e.platform?`--platform ${n(e.platform)}`:null,e.device?`--device ${n(e.device)}`:null,e.udid?`--udid ${n(e.udid)}`:null,e.serial?`--serial ${n(e.serial)}`:null].filter(e=>!!e);return[`agent-device device ${t}`,...r,`--stale`].join(` `)}export{s as deviceCommand};
|
package/dist/src/devicectl.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";import{f as t}from"./owner-identity.js";import{n}from"./exec.js";import"./command.js";import"./process.js";import{T as r,p as i,y as a}from"./host-file.js";import"./config.js";import{c as o,o as s}from"./tool-provider.js";import c from"node:path";async function l(t,r,i={}){let a=[`devicectl`,...t],o=await s(a,{allowFailure:!0,signal:i.signal,timeoutMs:i.timeoutMs??2e4});if(o.exitCode===0)return;let{stdout:c,stderr:l}=o;if(!i.tolerateOutput?.(c,l))throw new e(`COMMAND_FAILED`,`Failed to ${r.action}`,n(o,{cmd:`xcrun`,args:a,stdout:c,stderr:l,deviceId:r.deviceId,hint:
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{f as t}from"./owner-identity.js";import{n}from"./exec.js";import"./command.js";import"./process.js";import{T as r,p as i,y as a}from"./host-file.js";import"./config.js";import{c as o,o as s}from"./tool-provider.js";import c from"node:path";async function l(t,r,i={}){let a=[`devicectl`,...t],o=await s(a,{allowFailure:!0,signal:i.signal,timeoutMs:i.timeoutMs??2e4});if(o.exitCode===0)return;let{stdout:c,stderr:l}=o;if(!i.tolerateOutput?.(c,l))throw new e(`COMMAND_FAILED`,`Failed to ${r.action}`,n(o,{cmd:`xcrun`,args:a,stdout:c,stderr:l,deviceId:r.deviceId,hint:D(c,l)??`Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.`}))}async function u(e,t){return S(b(await h(e,{jsonPrefix:`agent-device-ios-apps`,args:[`devicectl`,`device`,`info`,`apps`,`--device`,e.id,`--include-all-apps`],failureMessage:`Failed to list iOS apps`,parseFailureMessage:`Failed to parse iOS apps list`})),t)}async function d(t){let n=await h(t,{jsonPrefix:`agent-device-ios-processes`,args:[`devicectl`,`device`,`info`,`processes`,`--device`,t.id],failureMessage:`Failed to list iOS processes`,parseFailureMessage:`Failed to parse iOS process list`,fallbackHint:w});if(!v(n))throw new e(`COMMAND_FAILED`,`Unsupported iOS process list response`,{deviceId:t.id,hint:w});return x(n)}async function f(e,t){let{appBundleUrl:n,processes:r}=await p(e,t),i=r.sort((e,t)=>_(e,n)-_(t,n))[0];i&&await h(e,{jsonPrefix:`agent-device-ios-process-terminate`,args:[`devicectl`,`device`,`process`,`terminate`,`--device`,e.id,`--pid`,String(i.pid),`--kill`],failureMessage:`Failed to terminate iOS app`,parseFailureMessage:`Failed to parse iOS process termination response`,tolerateFailurePayload:y})}async function p(t,n){let r=(await u(t,`all`)).find(e=>e.bundleId===n);if(!r)throw new e(`APP_NOT_INSTALLED`,`No iOS device app found for ${n}`,{appBundleId:n,deviceId:t.id});if(!r.url)throw new e(`COMMAND_FAILED`,`Missing app bundle URL for ${n}`,{appBundleId:n,deviceId:t.id,hint:`Installed-app metadata from devicectl did not include the bundle URL required to match running processes. Use an Xcode/CoreDevice toolchain that reports app URLs.`});let i=r.url.replace(/\/+$/,``);return{appBundleUrl:i,processes:(await d(t)).filter(e=>e.executable.startsWith(`${i}/`))}}async function m(n){let a=c.join(i(),`${n.jsonPrefix}-${t()}-${Date.now()}-${Math.random().toString(36).slice(2)}.json`),o=[...n.args,`--json-output`,a],l=await s(o,{allowFailure:!0,signal:n.signal,timeoutMs:n.timeoutMs??2e4});try{if(l.exitCode!==0){if(n.tolerateFailurePayload){let e=await g(a).catch(()=>void 0);if(e!==void 0&&n.tolerateFailurePayload(e))return{ok:!0,payload:e}}return{ok:!1,reason:`command-failed`,args:o,result:l}}return{ok:!0,payload:await g(a)}}catch(t){if(t instanceof e)throw t;return{ok:!1,reason:`unreadable-json`,args:o,result:l,cause:String(t)}}finally{await r(a).catch(()=>{})}}async function h(t,r){let i=await m(r);if(i.ok)return i.payload;if(i.reason===`command-failed`&&i.result){let{stdout:a,stderr:o}=i.result;throw new e(`COMMAND_FAILED`,r.failureMessage,n(i.result,{cmd:`xcrun`,args:i.args,stdout:a,stderr:o,deviceId:t.id,hint:D(a,o)??r.fallbackHint??`Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.`}))}throw new e(`COMMAND_FAILED`,r.parseFailureMessage,{deviceId:t.id,cause:i.cause})}async function g(e){return JSON.parse(await a(e))}function _(e,t){return e.executable.slice(t.length+1).split(`/`).length}function v(e){return Array.isArray(e?.result?.runningProcesses)}function y(e){let t=e?.error?.userInfo?.NSUnderlyingError?.error;return t?.domain===`NSPOSIXErrorDomain`&&t.code===3}function b(e){let t=e?.result?.apps;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=typeof e.bundleIdentifier==`string`?e.bundleIdentifier.trim():``;if(!t)continue;let r=typeof e.name==`string`&&e.name.trim().length>0?e.name.trim():t,i=typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():void 0;n.push({bundleId:t,name:r,url:i})}return n}function x(e){let t=e?.result?.runningProcesses;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=typeof e.executable==`string`?e.executable.trim():``,r=typeof e.processIdentifier==`number`&&Number.isFinite(e.processIdentifier)?e.processIdentifier:NaN;!t||!Number.isFinite(r)||n.push({executable:t,pid:r})}return n}function S(e,t){return o(e,t)}const C=`Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.`,w=`This Xcode/CoreDevice toolchain must support 'devicectl device info processes' with JSON runningProcesses so agent-device can resolve app process IDs. Inspect diagnostics for the exact devicectl API failure.`,T=`Enable Developer Mode on the iOS device (Settings > Privacy & Security > Developer Mode), restart it when prompted, unlock it, then retry.`,E=`Let Xcode finish preparing this device: keep it unlocked and connected by cable, open Xcode > Settings > Platforms (or Window > Devices and Simulators), wait for device support to install, then retry.`;function D(e,t){let n=`${e}\n${t}`.toLowerCase();return n.includes(`device is busy`)&&n.includes(`connecting`)?`iOS device is still connecting. Keep it unlocked and connected by cable until it is fully available in Xcode Devices, then retry.`:n.includes(`coredeviceservice`)&&n.includes(`timed out`)?`CoreDevice service timed out. Reconnect the device and retry; if it persists restart Xcode and the iOS device.`:n.includes(`developer mode is disabled`)?T:n.includes(`developer disk image`)?E:n.includes(`must be paired`)?`Pair the iOS device with this Mac: connect it by cable, unlock it, accept the Trust prompt, and enter the device passcode, then retry.`:null}export{p as a,m as c,u as i,f as l,E as n,D as o,T as r,l as s,C as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";import{
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{S as t,l as n,s as r}from"./sdk-device.js";import{c as i}from"./diagnostics.js";import"./diagnostics2.js";import{n as a,r as o}from"./device-isolation.js";import{a as s,i as c,r as l}from"./device-inventory-context.js";import{AsyncLocalStorage as u}from"node:async_hooks";async function d(e){let{resolveInventoryDeviceSelection:t}=await import(`./device-selection-resolver.js`).then(e=>e.t);return await t(e)}const f=new u;function p(t,n){return!r(n)&&t instanceof e&&t.code===`DEVICE_NOT_FOUND`}function m(e,t){return!r(e)&&(!e.platform||e.platform===`apple`||e.platform===`ios`)&&e.target!==`desktop`&&(!t||t.kind===`device`)}async function h(e,t={}){return(await g(e,t)).device}async function g(e,t={}){let r={...y(e),androidAvdSelection:t.androidAvdSelection??`running-only`},{iosSimulatorSetPath:a,...o}=r,s=C(r,t),l={platform:r.platform,target:e.target,cacheHit:!1};return await i(`resolve_target_device`,async()=>{let e=x(s);if(e)return l.cacheHit=!0,e;let i=await c(r),u=[...i.devices];if(n(o.platform)&&i.source===`local`){let e=await _(u,o,{simulatorSetPath:a,appleSimulatorAppTarget:t.appleSimulatorAppTarget});return S(s,e)}return S(s,await d({devices:u,selector:o,source:i.source}))},l)}async function _(t,n,r){let i;try{i=await d({devices:t,selector:n,source:`local`,appleSimulatorAppTarget:r.appleSimulatorAppTarget})}catch(e){if(!p(e,n))throw e}let a=await v(n,r,i?.device);if(a)return a;if(i)return i;throw new e(`DEVICE_NOT_FOUND`,`No devices found`,{selector:n})}async function v(e,t,n){if(m(e,n))try{return await d({devices:await l({platform:e.platform??`ios`,target:e.target,iosSimulatorSetPath:t.simulatorSetPath,kind:`simulator`}),selector:e,source:`local`})}catch(e){if(s(e))throw e;return}}function y(n){let r=n.platform;if(n.target&&!r)throw new e(`INVALID_ARGS`,`Device target selector requires --platform. Use --platform ios|macos|android|vega|linux|apple with --target mobile|tv|desktop.`);let i=t({simulatorSetPath:o(n.iosSimulatorDeviceSet),platform:r,target:n.target}),s=a(n.androidDeviceAllowlist);return{platform:r,target:n.target,deviceName:n.device,udid:n.udid,serial:n.serial,leaseId:n.leaseId,leaseProvider:n.leaseProvider,deviceKey:n.deviceKey,clientId:n.clientId,iosSimulatorSetPath:i,androidSerialAllowlist:s?Array.from(s).sort():void 0}}async function b(e){return f.getStore()?await e():await f.run(new Map,e)}function x(e){let t=f.getStore()?.get(e);if(t)return{...t,device:{...t.device}}}function S(e,t){return f.getStore()?.set(e,{...t,device:{...t.device}}),t}function C(e,t){let{appleSimulatorAppTarget:n,...r}=t;return JSON.stringify({request:e,options:r})}export{b as i,h as n,g as r,y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{r as t}from"./diagnostics.js";import{r as n}from"./exec.js";import"./diagnostics2.js";import"./command.js";import"./config.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{r as t}from"./diagnostics.js";import{r as n}from"./exec.js";import"./diagnostics2.js";import"./command.js";import"./config.js";import{c as r}from"./devicectl.js";var i=e({appleSimulatorDisplayArgvFragment:()=>S,buildInventory:()=>y,parseCoreDeviceDisplays:()=>u,queryAppleDisplayInventory:()=>s,readPanelPower:()=>_,resolveAppleCaptureDisplay:()=>x});const a=new Set([`activeOn`,`inactiveOn`,`activeDimmed`]),o=new Set([`off`]);async function s(e,t){try{let n=await r({jsonPrefix:`agent-device-apple-displays`,args:[`devicectl`,`device`,`info`,`displays`,`--device`,e.id],timeoutMs:t.timeoutMs??5e3,signal:t.signal});if(!n.ok)return c(e,n.reason,n.result?n.result.stderr.trim():n.cause??``),l();let i=u(n.payload);return i.length===0?(c(e,`empty-display-list`,``),l()):y(i)}catch(t){return c(e,n(t)?`probe-timed-out`:`probe-failed`,t instanceof Error?t.message:String(t)),l()}}function c(e,n,r){t({level:`warn`,phase:`apple_display_inventory_unresolved`,data:{platform:e.platform,deviceId:e.id,reason:n,...r?{detail:r}:{},...n===`command-failed`||n===`unreadable-json`?{hint:`This Xcode/CoreDevice toolchain does not report 'devicectl device info displays'. Update Xcode to a version that ships the display-information feature before targeting multi-display Apple devices.`}:{}}})}function l(){return{displays:[],multiScreen:!1,ambiguous:!1,unresolved:!0}}function u(e){let t=e?.result?.displays;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=d(e);t&&n.push(t)}return n}function d(e){let t=f(e);if(t)return{...t,power:_(e.backlightState,e.active),primary:e.primary===!0,currentOrientation:typeof e.currentOrientation==`string`?e.currentOrientation:`unknown`,integrated:v(e.type)}}function f(e){let t=p(e.name),n=h(e.displayId),r=g(e.pointScale),i=m(e.nativeSize);if(!(!t||n===void 0||r===void 0||!i))return{name:t,displayId:n,pointScale:r,widthPx:i.widthPx,heightPx:i.heightPx}}function p(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function m(e){if(!Array.isArray(e))return;let t=g(e[0]),n=g(e[1]);if(t!==void 0&&n!==void 0)return{widthPx:t,heightPx:n}}function h(e){return typeof e==`number`&&Number.isInteger(e)?e:void 0}function g(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function _(e,t){return typeof e==`string`?a.has(e)?`lit`:o.has(e)?`dark`:`unknown`:t===!0?`lit`:t===!1?`dark`:`unknown`}function v(e){return typeof e==`object`&&!!e&&Object.hasOwn(e,`integrated`)}function y(e){let n=e.filter(e=>e.integrated);if(n.length<2)return{displays:e,multiScreen:!1,ambiguous:!1,unresolved:!1};b(n);let r=n.filter(e=>e.power===`lit`),i=n.find(e=>e.primary),a=r.length===1,o=a?r[0]:i??r[0]??n[0],s=!a||i===void 0;return s&&t({level:`warn`,phase:`apple_display_capture_ambiguous`,data:{reason:i===void 0?`no-primary-panel`:`lit-panel-count`,litPanelCount:r.length,capturedDisplay:o.name,hint:`Panel power did not identify exactly one lit panel, so the capture names the primary panel without claiming to know which panel the device is showing. Read the device pose from the app under test with UIHinge.status.`}}),{displays:n,multiScreen:!0,activeDisplay:o,ambiguous:s,unresolved:!1}}function b(e){let n=e.find(e=>e.primary);if(!n)return;let r=e=>e.widthPx*e.heightPx,i=e.filter(e=>e!==n).reduce((e,t)=>r(t)>r(e)?t:e);r(n)<r(i)||t({level:`warn`,phase:`apple_display_primary_geometry_conflict`,data:{primaryDisplay:n.name,largestDisplay:i.name,hint:"CoreDevice reported the primary panel as at least as large as the other panel. CoreDevice `primary` still selects the capture fallback; verify the device type capabilities."}})}async function x(e,t={}){let n=await s(e,t);if(!(n.unresolved||!n.multiScreen))return n.activeDisplay}function S(e){return e?[`--display=${e.name}`]:[]}export{x as i,i as n,s as r,S as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e}from"./sdk-device.js";import{d as t}from"./owner-identity.js";import"./process.js";import{n}from"./toolchain-probe.js";import{r,s as i}from"./runner-client.js";async function a(){let e=await n(`xcodebuild`,[`-version`]);return e?s({selectedPath:await n(`xcode-select`,[`-p`]),versionLine:e}):u()}async function o(n,a){if(!(!e(n)||n.kind!==`simulator`)&&!(t()!==`darwin`||a.isProviderDevice(n)))return a.emitProgress(`Checking iOS runner build cache (${n.name})...`),await r(n)?{id:`ios-runner-cache`,status:`pass`,summary:`iOS runner artifact cached; first open skips the runner build`}:(i(n,{}),a.emitProgress(`Warming iOS runner build cache in the background (${n.name})...`),{id:`ios-runner-cache`,status:`pass`,summary:`iOS runner build started in the background; the first open gets faster once it completes`,hint:"Run `agent-device prepare ios-runner` to wait for a fully warmed runner instead."})}function s(e){return{id:`toolchain`,status:c(e),summary:l(e),evidence:{selectedPath:e.selectedPath??null,xcodeVersion:e.versionLine??null}}}function c(e){return e.versionLine?`pass`:`info`}function l(e){return e.versionLine?e.selectedPath?`Apple toolchain: ${e.versionLine}; xcode-select ${e.selectedPath}.`:`Apple toolchain: ${e.versionLine}; xcode-select path unavailable.`:`Apple toolchain: xcodebuild version check failed.`}function u(){return{id:`toolchain`,status:`info`,summary:`Apple toolchain: xcodebuild version check failed.`,hint:`Install/select Xcode and complete first launch/license setup if xcodebuild reports it.`,command:`xcodebuild -version`}}export{o as appleRunnerWarmupCheck,a as appleToolchainCheck};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,
|
|
1
|
+
import{c as e,m as t}from"./sdk-device.js";import{Qt as n,Xt as r,Yt as i}from"./sdk-batch.js";const a=4096;function o(e){return c(e,{seen:new WeakSet,nodes:0},0)}function s(e){return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,p(t)])))}function c(e,t,n){if(!d(e)||n>32||t.seen.has(e))return!1;t.seen.add(e),t.nodes+=1;let r=t.nodes<=a&&Object.values(e).every(e=>l(e,t,n+1));return t.seen.delete(e),r}function l(e,t,n){return f(e)?!0:n>32?!1:Array.isArray(e)?u(e,t,n):c(e,t,n)}function u(e,t,n){if(t.seen.has(e))return!1;t.seen.add(e),t.nodes+=1;let r=t.nodes<=a&&e.every(e=>l(e,t,n+1));return t.seen.delete(e),r}function d(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function f(e){return e===null?!0:typeof e==`number`?Number.isFinite(e):typeof e==`string`||typeof e==`boolean`}function p(e){return Array.isArray(e)?Object.freeze(e.map(p)):typeof e==`object`&&e?s(e):e}function m(e){if(!P(e))return _(`Durable resource envelope must be an object`);let t=e.envelopeVersion;if(!N(t))return _(`Durable resource envelopeVersion must be a non-negative integer`);if(t!==1)return{status:`unreattachable`,reason:`descriptor-version-unsupported`,message:`Unsupported durable resource envelope version: ${t}`,version:t};if(!M(e.resourceKind))return _(`Durable resource resourceKind must be a non-empty string`);if(!M(e.sessionId))return _(`Durable resource sessionId must be a non-empty string`);let n=y(e.device);if(!n)return _(`Durable resource device identity is invalid`);let r=v(e.owner);if(!r)return _(`Durable resource owner reference is invalid`);if(r.kind===`local-family`&&r.family!==n.family)return _(`Durable resource local owner does not match the device family`);let i=D(e.fence);if(!i)return _(`Durable resource ownership fence is invalid`);if(!k(e.lifecycle))return _(`Durable resource lifecycle state is invalid`);let a=O(e.descriptor);return a?e.metadata!==void 0&&!o(e.metadata)?_(`Durable resource metadata must be a JSON object`):{status:`decoded`,envelope:Object.freeze({envelopeVersion:1,resourceKind:e.resourceKind,sessionId:e.sessionId,device:n,owner:r,fence:i,lifecycle:e.lifecycle,descriptor:a,...e.metadata===void 0?{}:{metadata:s(e.metadata)}})}:_(`Durable resource descriptor is invalid`)}function h(e,t){return Object.freeze({version:e.version,body:s(e.encode(t))})}function g(e){let t=m({envelopeVersion:1,...e});if(t.status!==`decoded`)throw TypeError(t.message);return t.envelope}function _(e){return{status:`unreattachable`,reason:`descriptor-invalid`,message:e}}function v(e){return P(e)?e.kind===`local-family`&&t(e.family)?i(e.family):e.kind===`managed-local`&&M(e.instance)?r(e.instance):e.kind===`provider-runtime`&&M(e.provider)&&M(e.instance)?n(e.provider,e.instance):null:null}function y(e){if(!P(e))return null;let t=x(e.id),n=S(e.family),r=C(e.kind),i=w(e.target);return!t||!n||!r||i===null||!T(e,n,r)?null:b(e,t,n,r,i)}function b(e,t,n,r,i){return Object.freeze({id:t,family:n,...e.appleOs===void 0?{}:{appleOs:e.appleOs},kind:r,...i===void 0?{}:{target:i},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend}})}function x(e){return M(e)?e:null}function S(e){return t(e)?e:null}function C(e){return A(e)?e:null}function w(e){if(e!==void 0)return j(e)?e:null}function T(t,n,r){if(n===`apple`){if(!e(t.appleOs))return!1}else if(t.appleOs!==void 0||t.iosPhysicalDeviceBackend!==void 0)return!1;return E(t.iosPhysicalDeviceBackend,r)}function E(e,t){return e===void 0?!0:t===`device`?e===`coredevice`||e===`xctest`:!1}function D(e){return!P(e)||!M(e.token)||!N(e.generation)?null:Object.freeze({token:e.token,generation:e.generation})}function O(e){return!P(e)||!N(e.version)||!o(e.body)?null:Object.freeze({version:e.version,body:s(e.body)})}function k(e){return e===`open`||e===`completed`}function A(e){return e===`simulator`||e===`emulator`||e===`device`}function j(e){return e===`mobile`||e===`tv`||e===`desktop`}function M(e){return typeof e==`string`&&e.trim().length>0}function N(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0}function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function F(e){return e.status===`cleaned`||e.status===`already-missing`}export{h as a,m as i,g as n,y as r,F as t};
|
package/dist/src/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e,k as t}from"./sdk-contracts.js";import{o as n}from"./sdk-remote-config.js";import{a as r,r as i,s as a}from"./diagnostics.js";import o from"node:path";import{constants as s}from"node:fs";import{AsyncLocalStorage as c}from"node:async_hooks";import{access as l,stat as u}from"node:fs/promises";import{spawn as d,spawnSync as f}from"node:child_process";import{Readable as p}from"node:stream";import{pipeline as m}from"node:stream/promises";const h=/^[A-Za-z0-9][A-Za-z0-9._+-]*$/,g=[`.com`,`.exe`,`.bat`,`.cmd`],_=new c;async function v(e,t){return e?await _.run(e,t):await t()}async function y(e){return await _.run(void 0,e)}async function b(e,t,n={}){let r=_.getStore()?.(e,t,n);return r?S(await r):await C(e,t,n)}async function x(e,t,n={}){let r=_.getStore()?.(e,t,n);return r?S(await r):await C(e,t,n)}function S(e){let t=typeof e.stdout==`string`?e.stdout:String(e.stdout??``),n=typeof e.stderr==`string`?e.stderr:String(e.stderr??``),r=typeof e.exitCode==`number`?e.exitCode:1;return t===e.stdout&&n===e.stderr&&r===e.exitCode?e:{...e,stdout:t,stderr:n,exitCode:r}}function C(e,t,n={}){let r=
|
|
1
|
+
import{D as e,k as t}from"./sdk-contracts.js";import{o as n}from"./sdk-remote-config.js";import{a as r,r as i,s as a}from"./diagnostics.js";import o from"node:path";import{constants as s}from"node:fs";import{AsyncLocalStorage as c}from"node:async_hooks";import{access as l,stat as u}from"node:fs/promises";import{spawn as d,spawnSync as f}from"node:child_process";import{Readable as p}from"node:stream";import{pipeline as m}from"node:stream/promises";const h=/^[A-Za-z0-9][A-Za-z0-9._+-]*$/,g=[`.com`,`.exe`,`.bat`,`.cmd`],_=new c;async function v(e,t){return e?await _.run(e,t):await t()}async function y(e){return await _.run(void 0,e)}async function b(e,t,n={}){let r=_.getStore()?.(e,t,n);return r?S(await r):await C(e,t,n)}async function x(e,t,n={}){let r=_.getStore()?.(e,t,n);return r?S(await r):await C(e,t,n)}function S(e){let t=typeof e.stdout==`string`?e.stdout:String(e.stdout??``),n=typeof e.stderr==`string`?e.stderr:String(e.stderr??``),r=typeof e.exitCode==`number`?e.exitCode:1;return t===e.stdout&&n===e.stderr&&r===e.exitCode?e:{...e,stdout:t,stderr:n,exitCode:r}}function C(e,t,n={}){let r=j(e),i=k();return new Promise((a,o)=>{let s=d(r,t,{cwd:n.cwd,env:n.env,stdio:[`pipe`,`pipe`,`pipe`],detached:n.detached,windowsHide:!0,shell:!1});n.onSpawn?.(s);let c=``,l=n.binaryStdout?[]:void 0,u=``,f=!1,p=q(n.timeoutMs),m=null,h=!1;function g(){return!h&&(h=!0,m&&clearTimeout(m),b.dispose(),$(s),i.emitForegroundCompletion(e,t),!0)}function _(e){g()&&o(e)}function v(i){if(!g())return;let s=i??1;if(!b.didAbort&&f&&p){o(re(r,e,t,p,s,c,u));return}let d=B(b,r,e,t,s,n.allowFailure,c,u);if(d){o(d);return}a({stdout:c,stderr:u,exitCode:s,stdoutBuffer:l?Buffer.concat(l):void 0})}let y=J({killProcessTree:()=>Z(s,n),settle:v}),b=Y(n,y.requestKill);m=p?setTimeout(()=>{f=!0,y.requestKill()},p):null,n.binaryStdout||s.stdout.setEncoding(`utf8`),s.stderr.setEncoding(`utf8`),oe(s,n.stdin).catch(i=>{b.didAbort||f||se(i)||(_(F(r,e,t,i)),Z(s,n))}),s.stdout.on(`data`,e=>{if(n.binaryStdout){l?.push(Buffer.isBuffer(e)?e:Buffer.from(e));return}let t=String(e);c+=t,n.onStdoutChunk?.(t)}),s.stderr.on(`data`,e=>{let t=String(e);u+=t,n.onStderrChunk?.(t)}),s.on(`error`,n=>{_(z(b,r,e,t,n))}),s.once(`exit`,y.recordExit),s.once(`close`,v)})}async function ee(e){let t=H(e);if(!t)return!1;if(o.isAbsolute(t))return G(t);let n=process.env.PATH;if(!n)return!1;let r=U();for(let e of n.split(o.delimiter)){let n=e.trim();if(n){for(let e of W(t,r))if(await G(o.join(n,e)))return!0}}return!1}async function w(t,n){let r=V(t,n,`executable`);if(r){if(!await G(r))throw new e(`TOOL_MISSING`,`${n} points to a missing or non-executable file: ${r}`,{envName:n,path:r});return r}}async function T(t,n){let r=V(t,n,`file`);if(r){if(!await K(r))throw new e(`TOOL_MISSING`,`${n} points to a missing or non-file path: ${r}`,{envName:n,path:r});return r}}function E(t,n,r={}){let i=j(t),a=f(i,n,{cwd:r.cwd,env:r.env,stdio:[`pipe`,`pipe`,`pipe`],encoding:r.binaryStdout?void 0:`utf8`,input:r.stdin,timeout:q(r.timeoutMs),windowsHide:!0,shell:!1,...r.maxBuffer===void 0?{}:{maxBuffer:r.maxBuffer}});if(a.error){let o=a.error.code;throw o===`ETIMEDOUT`?new e(`COMMAND_FAILED`,`${i} timed out after ${q(r.timeoutMs)}ms`,{cmd:t,args:n,timeoutMs:q(r.timeoutMs)},a.error):o===`ENOENT`?N(i,t,a.error):P(i,t,n,a.error)}let o=r.binaryStdout?Buffer.isBuffer(a.stdout)?a.stdout:Buffer.from(a.stdout??``):void 0,s=r.binaryStdout?``:typeof a.stdout==`string`?a.stdout:(a.stdout??``).toString(),c=typeof a.stderr==`string`?a.stderr:(a.stderr??``).toString(),l=a.status??1;if(l!==0&&!r.allowFailure)throw L(i,t,n,l,s,c);return{stdout:s,stderr:c,exitCode:l,stdoutBuffer:o}}function D(e,t,n={}){return O(e,t,n).pid}function O(e,t,n={}){let r=j(e),i=d(r,t,{cwd:n.cwd,env:n.env,stdio:n.stdio??`ignore`,detached:!0,windowsHide:!0,shell:!1}),a=i.pid??0,o=new Promise(e=>{i.once(`error`,t=>{e({pid:a,error:t.message})}),i.once(`exit`,(t,n)=>{e({pid:a,...typeof t==`number`?{exitCode:t}:{},...n?{signal:n}:{}})})});return i.unref(),{pid:a,exited:o}}function te(e,t,n={}){let r=j(e),i=k(),a=d(r,t,{cwd:n.cwd,env:n.env,stdio:n.stdio??[`ignore`,`pipe`,`pipe`],detached:n.detached,windowsHide:!0,shell:!1});i.emitBackgroundSpawn(e,t);let o=``,s=``;return(n.captureOutput??!0)&&(a.stdout?.setEncoding(`utf8`),a.stderr?.setEncoding(`utf8`),a.stdout?.on(`data`,e=>{o+=e}),a.stderr?.on(`data`,e=>{s+=e})),{child:a,wait:new Promise((c,l)=>{let u=!1;function d(n){return!u&&(u=!0,m.dispose(),$(a),i.emitBackgroundCompletion(e,t,n),!0)}function f(i){if(!d(`exit`))return;let a=i??1,u=B(m,r,e,t,a,n.allowFailure,o,s);if(u){l(u);return}c({stdout:o,stderr:s,exitCode:a})}let p=J({killProcessTree:()=>Z(a,n),settle:f}),m=Y(n,p.requestKill);a.on(`error`,n=>{d(`error`)&&l(z(m,r,e,t,n))}),a.once(`exit`,p.recordExit),a.once(`close`,f)})}}function k(){let e=r(),t=e.debug===!0,i=n(process.env.AGENT_DEVICE_EXEC_TRACE??``)===!0;if(!t&&!i)return ne();i&&e.flushOnSuccess!==!0&&a({flushOnSuccess:!0});let o=Date.now(),s=!1;return{emitForegroundCompletion:(e,t)=>{s||(s=!0,A({cmd:e,args:t,startedAtMs:o}))},emitBackgroundSpawn:(e,t)=>{A({cmd:e,args:t,data:{event:`spawn`}})},emitBackgroundCompletion:(e,t,n)=>{s||(s=!0,A({cmd:e,args:t,startedAtMs:o,data:{event:n}}))}}}function ne(){return{emitForegroundCompletion:()=>{},emitBackgroundSpawn:()=>{},emitBackgroundCompletion:()=>{}}}function A(e){let t=e.args.slice(0,6);i({level:`debug`,phase:`exec_command`,durationMs:e.startedAtMs===void 0?void 0:Math.max(0,Date.now()-e.startedAtMs),data:{command:e.cmd,argsPrefix:t,...e.args.length>t.length?{omittedArgCount:e.args.length-t.length}:{},...e.data??{}}})}function j(t){let n=H(t);if(!n)throw new e(`INVALID_ARGS`,`Invalid executable command: ${JSON.stringify(t)}`,{cmd:t,hint:`Use a bare command name from PATH or an absolute executable path.`});return n}function M(e,t,n,r){return r.code===`ENOENT`?N(e,t,r):P(e,t,n,r)}function N(t,n,r){return new e(`TOOL_MISSING`,`${t} not found in PATH`,{cmd:n},r)}function P(t,n,r,i){return new e(`COMMAND_FAILED`,`Failed to run ${t}`,{cmd:n,args:r},i)}function F(t,n,r,i){return new e(`COMMAND_FAILED`,`Failed to write stdin for ${t}`,{cmd:n,args:r},i instanceof Error?i:void 0)}function I(e,n,r){return t({cmd:n,args:r,executable:e})}function re(t,n,r,i,a,o,s){return new e(`COMMAND_FAILED`,`${t} timed out after ${i}ms`,{cmd:n,args:r,stdout:o,stderr:s,exitCode:a,timeoutMs:i})}function ie(t){return t instanceof e&&t.code===`COMMAND_FAILED`&&typeof t.details?.timeoutMs==`number`}function L(t,n,r,i,a,o){return new e(`COMMAND_FAILED`,`${t} exited with code ${i}`,R({stdout:a,stderr:o,exitCode:i},{cmd:n,args:r}))}function ae(t,n,r){if(t.exitCode===0)return t;throw new e(`COMMAND_FAILED`,n,R(t,typeof r==`function`?r(t):r))}function R(e,t){return{stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,processExitError:!0,...t}}function z(e,t,n,r,i){return e.didAbort?I(t,n,r):M(t,n,r,i)}function B(e,t,n,r,i,a,o,s){return e.didAbort?I(t,n,r):i!==0&&!a?L(t,n,r,i,o,s):null}function V(t,n,r){let i=t?.trim();if(i){if(!o.isAbsolute(i)||i.includes(`\0`))throw new e(`INVALID_ARGS`,`${n} must be an absolute ${r} path, not ${JSON.stringify(t)}`,{envName:n,path:t});return i}}function H(e){let t=e.trim();return!t||t.includes(`\0`)?null:o.isAbsolute(t)?t:t.includes(`/`)||t.includes(`\\`)?null:h.test(t)?t:null}function U(){if(process.platform!==`win32`)return[``];let e=process.env.PATHEXT;if(!e)return g;let t=e.split(`;`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0);return t.length>0?t:g}function W(e,t){if(process.platform!==`win32`)return[e];let n=e.toLowerCase();return t.some(e=>n.endsWith(e))?[e]:t.map(t=>`${e}${t}`)}async function G(e){try{return await K(e)?(await l(e,process.platform===`win32`?s.F_OK:s.X_OK),!0):!1}catch{return!1}}async function K(e){try{return(await u(e)).isFile()}catch{return!1}}function q(e){if(!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t}function J(e){let t=!1,n=!1,r=null,i=()=>{t&&n&&e.settle(r)};return{requestKill:()=>{t=!0,e.killProcessTree(),i()},recordExit:e=>{n=!0,r=e??1,i()}}}function Y(e,t){let n=!1,r=()=>{n=!0,t()};return e.signal?.aborted?r():e.signal?.addEventListener(`abort`,r,{once:!0}),{get didAbort(){return n},dispose:()=>{e.signal?.removeEventListener(`abort`,r)}}}function X(e,t){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(-e,t),!0}catch{return!1}}function Z(e,t){if(!t.kill){Q(e,t.detached,`SIGKILL`);return}Q(e,t.detached,t.kill.signal);let n=setTimeout(()=>Q(e,t.detached,`SIGKILL`),t.kill.graceMs);n.unref(),e.once(`exit`,()=>clearTimeout(n))}function Q(e,t,n){if(t&&e.pid&&process.platform!==`win32`){X(e.pid,n);return}e.exitCode===null&&e.signalCode===null&&e.kill(n)}function $(e){e.stdin?.destroy(),e.stdout?.destroy(),e.stderr?.destroy()}async function oe(e,t){if(e.stdin){if(t===void 0){e.stdin?.end();return}await m(p.from([t]),e.stdin)}}function se(e){return e instanceof Error&&`code`in e&&e.code===`EPIPE`}export{y as _,ae as a,b as c,O as d,x as f,v as g,ee as h,G as i,te as l,X as m,R as n,w as o,E as p,ie as r,T as s,S as t,D as u};
|
package/dist/src/find.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,o as t,u as n}from"./sdk-contracts.js";import{
|
|
1
|
+
import{g as e,o as t,u as n}from"./sdk-contracts.js";import{Ln as r,Lt as i,Mn as a,Nn as o,Pn as s,gt as c}from"./sdk-batch.js";import{c as l}from"./session-store.js";import{M as u,O as d,k as f}from"./session-snapshot.js";import{C as p,S as m,c as h,h as g,u as _}from"./runtime.js";import{r as v,t as y}from"./success-text.js";import{f as b}from"./absence-observation-errors.js";import{s as x}from"./quality-warnings.js";import{t as S}from"./internal/daemon.js";import{n as C}from"./capture-disclosure.js";import{t as w}from"./snapshot-runtime-binding.js";import{l as T,n as E}from"./selector-runtime.js";import{t as D}from"./type-text-runtime.js";function O(t,n){let r=n[0]?.rect;if(!r)return t;let i=t.filter(t=>{if(!t.rect)return!1;let n=e(t.rect);return n.x>=r.x&&n.x<=r.x+r.width&&n.y>=r.y&&n.y<=r.y+r.height}),a=i.length>0?i:t;return a.length<2?a:k(a,n,m(n))}function k(e,t,n){return e.map((e,r)=>({node:e,index:r,score:A(e,t,n)})).sort((e,t)=>t.score===e.score?M(e.node)-M(t.node)||e.index-t.index:t.score-e.score).map(e=>e.node)}function A(e,t,n){let r=n(e);if(r.reason===`covered`)return 0;let i=j(r,t[0]);return i>0?i:e.hittable&&e.rect&&!p(e,t[0])?3:+!!e.rect}function j(e,t){return e.node.rect?e.reason===`semantic-target`||e.reason===`same-rect-descendant`?4:e.reason===`hittable-ancestor`&&!p(e.node,t)?2:0:0}function M(e){return e.rect?e.rect.width*e.rect.height:1/0}function N(e,n,r){let i={matches:e.length,candidates:e.slice(0,5).map(e=>b(e,0,!1))};return t(`AMBIGUOUS_MATCH`,`find matched ${e.length} elements for ${n} "${r}". Use a more specific locator or selector.`,{locator:n,query:r,...i})}function P(e){if(e.ambiguity!==`reject-candidates`)throw Error(`find's resolution policy must reject candidates, got "${e.ambiguity}"`)}function F(e){let{nodes:n,locator:r,query:i,selectorExpression:a,flags:s,platform:c}=e,l=g.findAct,u=n.filter(e=>!p(e,n[0])),d=l.resolution,f;if(f=a?h(l,u,a,{platform:c}).list?.matchedNodes??[]:o(u,r,i,{requireRect:d.requireRect}).matches,f=O(f,n),f.length>1){P(d);let e=I(f,s);if(!e)return{ok:!1,response:N(f,r,i)};f=e}let m=f[0]??null;return m?{ok:!0,node:m}:{ok:!1,response:t(`COMMAND_FAILED`,`find did not match any element`)}}function I(e,t){return t?.findFirst?[e[0]]:t?.findLast?[e.at(-1)]:null}function L(e){let{device:t,session:n,req:r,logPath:i,locator:a,query:o,sessionStore:s,sessionName:c}=e,l=T({device:t,session:n,sessionStore:s,sessionName:c,req:r,logPath:i,capture:e.capture,activationProof:e.activationProof});return async()=>{let{snapshot:e}=await l.capture({flags:{...r.flags,snapshotInteractiveOnly:!0},recovery:{legacyIosSparse:{query:o,shouldScope:z(a)},sparseVerdictQueryScope:{query:o,shouldScope:z(a)}}});return{nodes:e.nodes,snapshotQuality:e.snapshotQuality,systemSurfaceOnly:e.systemSurfaceOnly,iosSystemSurfaceBundleId:e.iosSystemSurfaceBundleId,...e.keyboard?{keyboard:e.keyboard}:{}}}}function R(e){return t(`COMMAND_FAILED`,`find could not read the current accessibility tree`,{reason:e.reason,hint:`The snapshot quality verdict is sparse. Use screenshot as visual truth, navigate with coordinates if needed, then retry find after reaching a readable screen.`})}function z(e){return e!==`role`}async function B(e){let{req:o,sessionName:l,logPath:u,sessionStore:d,invoke:f}=e,p=o.command;if(p!==`find`)return null;let m=o.positionals??[],h=a(m,o.flags);if(!h.ok)return t(h.code,h.message);let{locator:v,query:y,action:b,value:S}=h.parsed;if(o.flags?.record&&!s(b))return t(`INVALID_ARGS`,`find ${b} is a mutating action and is always recorded; --record only applies to a read-only find (exists, wait, list, get text, get attrs).`);let T=await E({req:o,sessionName:l,logPath:u,sessionStore:d,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(T)return T;let D=d.get(l);if(!D)return n();let O=D.device,k=await w({command:`find`,device:O,session:D,plan:i({hasActiveApp:D.appBundleId!==void 0,intent:c(b)}),inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(!k.ok)return k.response;let A=r(v,y),j={},M=L({device:O,session:D,req:o,logPath:u,locator:v,query:y,sessionStore:d,sessionName:l,capture:k.capture,activationProof:j}),N={req:o,sessionName:l,logPath:u,sessionStore:d,invoke:f,session:D,device:O,command:p,locator:v,query:y,publicFlags:X(o.flags),boundFocusPoint:k.focusPoint,boundTypeText:k.typeText},P=await M();if(x(P.snapshotQuality))return C({response:R(P.snapshotQuality),consumedTree:P,activationProof:j});let{nodes:I}=P,z=F({nodes:I,locator:v,query:y,selectorExpression:A,flags:o.flags,platform:O.platform});if(!z.ok)return C({response:z.response,consumedTree:P,activationProof:j});let B=z.node,H=await _(g.findAct,I,B),U=H.node,W=`@${U.ref}`,G={...o.flags??{},noRecord:!0},K=await V(N,{node:B,resolvedNode:U,ref:W,nodes:I,...P.iosSystemSurfaceBundleId?{iosSystemSurfaceBundleId:P.iosSystemSurfaceBundleId}:{},...P.keyboard?{keyboard:P.keyboard}:{},actionFlags:G,...H.kind===`occluded`?{occludedNode:H.node}:{}},b,S);return K&&C({response:K,consumedTree:P,activationProof:j})}async function V(e,t,n,r){let i={click:()=>U(e,t),fill:()=>W(e,t,r),focus:()=>G(e,t),type:()=>K(e,t,r)}[n];return i?await i():null}function H(e){return{ref:e.ref,node:e.resolvedNode,nodes:e.nodes,...e.iosSystemSurfaceBundleId?{iosSystemSurfaceBundleId:e.iosSystemSurfaceBundleId}:{},...e.keyboard?{keyboard:e.keyboard}:{}}}async function U(t,n){let{req:r,sessionName:i,sessionStore:a,session:o,invoke:s,command:c,locator:u,query:d,publicFlags:f}=t,p=await s({token:r.token,session:i,command:`click`,positionals:[n.ref],flags:n.actionFlags,internal:{findResolvedTarget:H(n)}});if(!p.ok)return p;let m=n.resolvedNode.rect?e(n.resolvedNode.rect):n.node.rect?e(n.node.rect):null,h={ref:n.ref,locator:u,query:d};m&&(h.x=m.x,h.y=m.y);let g=y(p.data)??`Tapped ${n.ref}${m?` (${m.x}, ${m.y})`:``}`;return Object.assign(h,v(g)),l(a,o,r,c,{ref:n.ref,action:`click`,locator:u,query:d},{flags:f}),{ok:!0,data:h}}async function W(e,n,r){let{req:i,sessionName:a,sessionStore:o,session:s,invoke:c,command:u,publicFlags:d}=e;if(r===void 0)return t(`INVALID_ARGS`,`find fill requires text (use "" to clear the field)`);let f=await c({token:i.token,session:a,command:`fill`,positionals:[n.ref,r],flags:n.actionFlags,internal:{findResolvedTarget:H(n)}});return f.ok&&l(o,s,i,u,{ref:n.ref,action:`fill`},{flags:d}),f}async function G(e,t){let n=await q(e,t);return n.ok&&Y(e,t,`focus`),n}async function K(e,n,r){let{req:i,logPath:a,session:o}=e;if(!r)return t(`INVALID_ARGS`,`find type requires text`);let s=await q(e,n);if(!s.ok)return s;u(o);let c=e.boundTypeText;if(!c)return t(`COMMAND_FAILED`,`find type was admitted without a text-entry operation`);let l=await D({operations:{typeText:c}},[r],f(a,i.flags,o.appBundleId,o.trace?.outPath));return Y(e,n,`type`),{ok:!0,data:l??{ref:n.ref}}}async function q(n,r){let{req:i,logPath:a,session:o}=n,s=J(r,`be focused`);if(s)return s;let c=r.resolvedNode.rect?e(r.resolvedNode.rect):null;if(!c)return t(`COMMAND_FAILED`,`matched element has no bounds`);u(o);let l=n.boundFocusPoint;return l?{ok:!0,data:await S({operations:{focusPoint:l}},c,f(a,i.flags,o.appBundleId,o.trace?.outPath))??{ref:r.ref}}:t(`COMMAND_FAILED`,`find focus was admitted without a focus operation`)}function J(e,n){let r=e.occludedNode;return r?t(`COMMAND_FAILED`,`Matched element ${e.ref} is covered by another visible element and cannot ${n} safely`,{ref:`@${r.ref}`,interactionBlocked:r.interactionBlocked,hint:`Use a different visible target, scroll it clear of the overlay, or inspect with snapshot/screenshot before retrying.`}):null}function Y(e,t,n){let{req:r,sessionStore:i,session:a,command:o,publicFlags:s}=e;l(i,a,r,o,{ref:t.ref,action:n},{flags:s})}function X(e){return{...d(e)??{}}}export{B as handleFindCommands};
|
package/dist/src/finders.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{In as e}from"./sdk-batch.js";import{t}from"./sdk-finders.js";export{t as findBestMatchesByLocator,e as parseFindArgs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`native-panel`;function t(e){return Object.freeze({setFoldPose:e.fold})}export{t as n,e as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{l as e,w as t}from"./sdk-device.js";const n={ios:`iOS`,ipados:`iPadOS`,tvos:`tvOS`,watchos:`watchOS`,visionos:`visionOS`,macos:`macOS`},r=`Target-authored drag requires an adapter that preserves source hold, timed movement, and destination hold; it is supported on Android touch devices and iOS/iPadOS.`,i=`Android TV has no touch input — this gesture is supported on Android phones, tablets, and the iOS simulator only.`,a=`Two-finger gesture synthesis is iOS-simulator only — not available on physical iOS devices.`;function o(e,t){return(t===`multi-touch`?s(e):t===`directional-fling`&&e.platform===`linux`?`Linux`:void 0)??e.appleOs??e.platform}function s(r){if(r.platform===`android`)return r.target===`tv`?`Android TV`:void 0;if(!e(r.platform))return;let i=t(r);if(i===`ios`||i===`ipados`)return`physical iOS devices`;if(i===`macos`||i===`tvos`||i===`visionos`)return n[i]}function c(e,t,n){return`gesture ${n} is not supported on ${o(e,t)}`}export{c as a,r as i,n,a as r,i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e,L as t}from"./sdk-contracts.js";import{
|
|
1
|
+
import{D as e,L as t}from"./sdk-contracts.js";import{Pt as n,yt as r}from"./sdk-batch.js";import{g as i,h as a,m as o}from"./session-snapshot.js";import{a as s}from"./gesture-admission.js";async function c(e){let t=await i({command:`runtime gesture-viewport`,device:e.device,use:r,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});return t.type===`response`?{ok:!1,response:t.response}:{ok:!0,read:d(t.runtime).gestureViewport}}async function l(r){let i=n(r.input),o=await a({command:`gesture`,device:r.device,required:i.use.required,inspectFacts:r.inspectFacts,bindDevice:r.bindDevice,unavailableResponse:n=>({ok:!1,error:t(new e(`UNSUPPORTED_OPERATION`,s(r.device,i.tier,r.input.intent),{gesture:r.input.intent,...n.hint===void 0?{}:{hint:n.hint}}))})});return o.type===`response`?{ok:!1,response:o.response}:{ok:!0,gestures:await u(o.bind,r.device,i)}}async function u(e,t,n){switch(n.tier){case`plan`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performGesturePlan(f(e,t)),...d(r)}}case`directional-fling`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performDirectionalFlingPlan(f(e,t)),...d(r)}}case`multi-touch`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performMultiTouchGesturePlan(f(e,t)),...d(r)}}case`target-authored-drag`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performTargetAuthoredDrag(f(e,t)),...d(r)}}}}function d(e){let{gestureViewport:t}=e.operations,n=e.operations.captureSnapshot?{operations:{captureSnapshot:e.operations.captureSnapshot}}:void 0,r=t?{operations:{gestureViewport:t}}:void 0;return Object.freeze({...n?{captureSnapshot:async e=>await n.operations.captureSnapshot(e)}:{},...r?{gestureViewport:async e=>await r.operations.gestureViewport(p(e))}:{}})}function f(e,t){return{plan:e,...t.appBundleId===void 0?{}:{options:{appBundleId:t.appBundleId}},execution:o(t)}}function p(e){return{...e.appBundleId===void 0?{}:{options:{appBundleId:e.appBundleId}},execution:o(e)}}export{c as n,l as t};
|
package/dist/src/harmonyos.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";import{c as t}from"./diagnostics.js";import"./diagnostics2.js";import{_ as n,a as r,c as i,d as a,f as o,g as s,h as c,l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _,x as v,y}from"./src4.js";function b(b,x){let S=t=>async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} is not supported on HarmonyOS`)};return{open:(e,t)=>l(b,e,{activity:t?.activity}),openDevice:()=>m(b),close:e=>p(b,e),tap:(e,t)=>a(b,e,t),doubleTap:(e,t)=>r(b,e,t),longPress:(e,t,n)=>i(b,e,t,n),focus:(e,t)=>a(b,e,t),type:(e,t)=>v(b,e,t),fill:(e,t,n,r)=>d(b,e,t,n,r),scroll:(e,t)=>s(b,e,t),performGesture:e=>g(b,e),gestureViewport:()=>f(b),screenshot:e=>c(b,e),snapshot:async e=>({...await t(`snapshot_capture`,async()=>await y(b,e),{backend:`harmonyos-arkui`}),backend:`harmonyos-arkui`,producer:`harmonyos-uitest`}),back:()=>u(b),home:()=>m(b),setOrientation:e=>n(b,e),appSwitcher:()=>h(b),
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{c as t}from"./diagnostics.js";import"./diagnostics2.js";import{_ as n,a as r,c as i,d as a,f as o,g as s,h as c,l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _,x as v,y}from"./src4.js";function b(b,x){let S=t=>async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} is not supported on HarmonyOS`)};return{open:(e,t)=>l(b,e,{activity:t?.activity}),openDevice:()=>m(b),close:e=>p(b,e),tap:(e,t)=>a(b,e,t),doubleTap:(e,t)=>r(b,e,t),longPress:(e,t,n)=>i(b,e,t,n),focus:(e,t)=>a(b,e,t),type:(e,t)=>v(b,e,t),fill:(e,t,n,r)=>d(b,e,t,n,r),scroll:(e,t)=>s(b,e,t),performGesture:e=>g(b,e),gestureViewport:()=>f(b),screenshot:e=>c(b,e),snapshot:async e=>({...await t(`snapshot_capture`,async()=>await y(b,e),{backend:`harmonyos-arkui`}),backend:`harmonyos-arkui`,producer:`harmonyos-uitest`}),back:()=>u(b),home:()=>m(b),setOrientation:e=>n(b,e),appSwitcher:()=>h(b),tvRemote:S(`tv-remote`),keyboardDismiss:async()=>(await o(b,`Back`),{kind:`acknowledged`}),keyboardEnter:async()=>(await o(b,`Enter`),{kind:`harmonyos-acknowledged`}),readClipboard:S(`clipboard`),writeClipboard:S(`clipboard`),setSetting:(e,t,n)=>_(b,e,t,n),readAlert:S(`alert`),awaitAlert:S(`alert`),acceptAlert:S(`alert`),dismissAlert:S(`alert`)}}export{b as createHarmonyInteractor};
|
package/dist/src/helper.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import{T as n,_ as r,d as i}from"./owner-identity.js";import{l as a,o}from"./exec.js";import"./command.js";import"./process.js";import{D as s,c,f as l,g as u,h as d,n as f,o as p,r as m,t as h,w as g,y as _}from"./host-file.js";import{a as v,i as y,n as b}from"./tool-provider.js";import x from"node:path";import{createHash as S}from"node:crypto";import{fileURLToPath as C}from"node:url";var w=e({quitMacOsApp:()=>
|
|
2
|
-
`),await v(`swift`,[`build`,`-c`,`release`,`--package-path`,t],{cwd:t,timeoutMs:12e4}),await p(D);let l=`${a}.tmp`;return await m(c,l),await g(l,a),await f(a,493),await s(O,`${JSON.stringify({fingerprint:i},null,2)}\n`),a}async function B(){let e=r(E)?.trim();if(e){let t=await o(e,E);if(t)return t}if(b())return T;if(i()!==`darwin`)throw new t(`UNSUPPORTED_PLATFORM`,`macOS helper is only available on macOS`);return await z()}async function V(e){let t=await B();return a(t,[`audio-probe`,`--duration-ms`,String(e.durationMs),`--bucket-ms`,String(e.bucketMs),`--out`,e.statusPath],{allowFailure:!0,captureOutput:!0})}async function
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import{T as n,_ as r,d as i}from"./owner-identity.js";import{l as a,o}from"./exec.js";import"./command.js";import"./process.js";import{D as s,c,f as l,g as u,h as d,n as f,o as p,r as m,t as h,w as g,y as _}from"./host-file.js";import{a as v,i as y,n as b}from"./tool-provider.js";import x from"node:path";import{createHash as S}from"node:crypto";import{fileURLToPath as C}from"node:url";var w=e({macOsClickScheduleMs:()=>X,quitMacOsApp:()=>G,resolveFrontmostMacOsApp:()=>W,resolveMacOsHelperPackageRootFrom:()=>M,runMacOsAlertAction:()=>q,runMacOsDeviceHubPoseAction:()=>Q,runMacOsPermissionAction:()=>K,runMacOsPressAction:()=>Z,runMacOsReadTextAction:()=>Y,runMacOsScreenshotAction:()=>$,runMacOsSnapshotAction:()=>J,startMacOsAudioProbeProcess:()=>V});const T=`agent-device-macos-helper`,E=`AGENT_DEVICE_MACOS_HELPER_BIN`,D=x.join(l(),`.agent-device`,`macos-helper`,`current`),O=x.join(D,`manifest.json`),k=/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)+$/;function A(e){let n=e.trim();if(!k.test(n))throw new t(`INVALID_ARGS`,`macOS bundle id must use reverse-DNS form like com.example.App`,{bundleId:e});return n}function j(e,t){t.bundleId&&e.push(`--bundle-id`,A(t.bundleId)),t.surface&&e.push(`--surface`,t.surface)}function M(e){let n=x.dirname(e);for(;;){let e=x.join(n,`apple`,`macos-helper`);if(c(x.join(e,`Package.swift`)))return e;let t=x.dirname(n);if(t===n)break;n=t}throw new t(`COMMAND_FAILED`,`Unable to locate macOS helper package root`,{modulePath:e})}function N(){return M(C(import.meta.url))}function P(){return x.join(N(),`.build`,`release`,T)}function F(){return x.join(D,T)}async function I(e){let t=await u(e,{withFileTypes:!0});return(await Promise.all(t.map(async t=>{let n=x.join(e,t.name);return t.isDirectory()?t.name===`.build`?[]:await I(n):!t.isFile()||!t.name.endsWith(`.swift`)&&t.name!==`Package.swift`?[]:[n]}))).flat().sort()}async function L(e){let t=await I(e),n=S(`sha256`);for(let r of t)n.update(x.relative(e,r)),n.update(`\0`),n.update(await d(r)),n.update(`\0`);let r=await v(`swift`,[`--version`],{allowFailure:!0,cwd:e,timeoutMs:1e4});return n.update(`swift-version`),n.update(`\0`),n.update(r.stdout||r.stderr||`exit:${r.exitCode}`),n.update(`\0`),n.digest(`hex`)}async function R(){try{let e=JSON.parse(await _(O));return typeof e.fingerprint==`string`?e.fingerprint:null}catch{return null}}async function z(){let e=await o(r(E),E);if(e)return e;let t=N(),i=await L(t),a=F();try{if(await R()===i)return await h(a),a}catch{}let c=P();n(`agent-device: building macOS helper (first run or helper update)
|
|
2
|
+
`),await v(`swift`,[`build`,`-c`,`release`,`--package-path`,t],{cwd:t,timeoutMs:12e4}),await p(D);let l=`${a}.tmp`;return await m(c,l),await g(l,a),await f(a,493),await s(O,`${JSON.stringify({fingerprint:i},null,2)}\n`),a}async function B(){let e=r(E)?.trim();if(e){let t=await o(e,E);if(t)return t}if(b())return T;if(i()!==`darwin`)throw new t(`UNSUPPORTED_PLATFORM`,`macOS helper is only available on macOS`);return await z()}async function V(e){let t=await B();return a(t,[`audio-probe`,`--duration-ms`,String(e.durationMs),`--bucket-ms`,String(e.bucketMs),`--out`,e.statusPath],{allowFailure:!0,captureOutput:!0})}const H=3e4;async function U(e,n={}){let r={allowFailure:!0,timeoutMs:n.timeoutMs??H,signal:n.signal,kill:{signal:`SIGTERM`,graceMs:1e3}},i=y().macosHelper,a=i?T:await B(),o=i?await i.run(e,r):await v(a,e,r),s=o.stdout.trim(),c=null;if(s)try{c=JSON.parse(s)}catch{c=null}if(o.exitCode===0&&c?.ok)return c.data;let l=c&&!c.ok?c.error?.message??`macOS helper exited with code ${o.exitCode}`:s||o.stderr.trim()||`macOS helper exited with code ${o.exitCode}`;throw new t(`COMMAND_FAILED`,l,{helperPath:a,args:e,stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode,...c&&!c.ok?c.error?.details:{}})}async function W(){return await U([`app`,`frontmost`])}async function G(e){return await U([`app`,`quit`,`--bundle-id`,A(e)])}async function K(e,t){return await U([`permission`,e,t])}async function q(e,t={}){let n=[`alert`,e];return j(n,t),await U(n)}async function J(e,t={}){let n=[`snapshot`,`--surface`,e];return j(n,t),await U(n,{signal:t.signal})}async function Y(e,t,n={}){let r=[`read`,`--x`,String(e),`--y`,String(t)];return j(r,n),await U(r)}function X(e){let t=e.holdMs&&e.holdMs>0?Math.max(e.holdMs,40):60,n=Math.max(e.clicks??1,1),r=Math.max(e.intervalMs??120,0);return n*(e.doubleClick?2*t+80:t)+(n-1)*r}async function Z(e,t,n={}){let r=[`press`,`--x`,String(e),`--y`,String(t)];n.holdMs&&n.holdMs>0&&r.push(`--hold-ms`,String(n.holdMs));let i=n.clicks??1;return i>1&&(r.push(`--clicks`,String(i)),n.intervalMs!==void 0&&r.push(`--interval-ms`,String(Math.max(n.intervalMs,0)))),n.doubleClick&&r.push(`--double-click`),j(r,n),await U(r,{signal:n.signal,timeoutMs:X(n)+H})}async function Q(e){return await U([`device-hub`,`pose`,`--udid`,e.udid,`--device-name`,e.deviceName,`--pose`,e.pose],{signal:e.signal})}async function $(e,t={}){let n=[`screenshot`,`--out`,e];return j(n,t),t.fullscreen&&n.push(`--fullscreen`),await U(n)}export{Q as a,V as c,q as i,G as n,K as o,W as r,$ as s,w as t};
|
package/dist/src/host.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e;function t(t){if(e&&e!==t)throw Error(`Apple runner host is already bound to a different implementation.`);e=t}function n(){if(!e)throw Error(`Apple runner host is not bound. Construct the client via createAppleRunnerClient() before using runner operations.`);return e}function r(e){return((...t)=>n()[e](...t))}const i=r(`runCmdStreaming`),a=r(`runCmdSync`),o=r(`runCmdBackground`),s=r(`requireExecSuccess`),c=r(`isCommandTimeoutError`),l=r(`shellQuote`),u=r(`emitDiagnostic`),d=r(`withDiagnosticTimer`),f=r(`retryWithPolicy`),p=r(`isEnvTruthy`),m=r(`isProcessAlive`),h=r(`isProcessGroupAlive`),g=r(`readProcessStartTime`),_=r(`readProcessCommand`),v=r(`signalPidsBestEffort`),y=r(`signalProcessGroupBestEffort`),b=r(`classifyOwnerLiveness`),x=r(`findProjectRoot`),S=r(`readVersion`),C=r(`acquireProcessLock`),w=r(`withProcessLock`),T=r(`publishFileSync`),E=r(`emitRequestProgress`),D=r(`getRequestSignal`),O=r(`isRequestCanceled`),k=r(`withKeyedLock`),A=r(`createTtlMemo`),j=r(`isRecord`),M=r(`parseBooleanLiteral`),N=r(`resolveIosSimulatorDeviceSetPath`),P=r(`classifyBootFailure`),F=r(`bootFailureHint`),I=r(`runAppleToolCommand`),L=r(`runXcrun`),R=r(`readApplePlistJson`),z=r(`buildSimctlArgsForDevice`),B=r(`visitXmlPlistEntries`),V=r(`resolveIosPhysicalDeviceControl`),H=r(`leaseOwnerStateDir`),U=r(`hasDeviceClaimAuthority`),W={fromTimeoutMs:r(`deadlineFromTimeoutMs`)};export{f as A,d as B,R as C,s as D,S as E,L as F,w as H,l as I,v as L,o as M,i as N,V as O,a as P,y as R,T as S,g as T,k as V,h as _,z as a,H as b,A as c,x as d,D as f,m as g,p as h,F as i,I as j,N as k,u as l,c as m,C as n,P as o,U as p,t as r,b as s,W as t,E as u,j as v,_ as w,M as x,O as y,B as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";import{
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{Sr as t,_r as n,br as r,vr as i,yr as a}from"./sdk-batch.js";function o(e){return e?.startsWith(`@`)?e.slice(1):e}const s=/^e\d+$/;function c(n){if(n[0]?.startsWith(`@`)){let e=_(n.slice(1));return{ref:n[0],...e===void 0?{}:{label:e}}}if(s.test(n[0]??``))throw new e(`INVALID_ARGS`,`Did you mean "@${n[0]}"? Snapshot refs need the @ prefix.`);let r=t(n);if(r){if(r.rest.length>0)throw new e(`INVALID_ARGS`,m(n,r));return{selector:r.selectorExpression}}return u(n)}function l(n){let r=n[0];if(r?.startsWith(`@`)){let e=n.slice(1),t=e.length===0?void 0:e.join(` `);return{kind:`ref`,target:{ref:r},text:t}}if(s.test(r??``))throw new e(`INVALID_ARGS`,`Did you mean "@${r}"? Snapshot refs need the @ prefix.`);let i=t(n,{preferTrailingValue:!0});if(i)return{kind:`selector`,target:{selector:i.selectorExpression},text:i.rest.length===0?void 0:i.rest.join(` `)};let a=n.slice(2);return{kind:`point`,target:u(n.slice(0,2)),text:a.length===0?void 0:a.join(` `)}}function u(t){let n=t[0]??``,r=i(n);if(r){let i=d(n)?r.value:[r.value,...t.slice(1)].join(` `).trim();throw new e(`INVALID_ARGS`,f({key:r.key,value:i}))}let a=Number(t[0]),o=Number(t[1]);if(Number.isFinite(a)&&Number.isFinite(o))return{x:a,y:o};throw new e(`INVALID_ARGS`,p(t))}function d(e){let t=e.slice(e.indexOf(`=`)+1).trim();if(t.length<2)return!1;let n=t[0];return(n===`"`||n===`'`)&&t.endsWith(n)}function f(e){let{key:t,value:r}=e;return`Unknown selector key "${t}". Supported: ${n.join(`, `)}. ${a(t)?`Did you mean role=${t} label=${g(r)}?`:`Did you mean label=${g(r)}?`}`}function p(e){let t=e.filter(e=>e!==void 0).join(` `);if(!t.trim())return`Missing target. Pass an @ref from snapshot, a selector like text="Sign in", or "x y" coordinates.`;let n=`Target "${t}" is not a @ref, selector, or "x y" point.`;return e.some(e=>r(e??``))?`${n} Selector values with spaces need quotes, e.g. text="Sign in".`:`${n} To match by visible text, use text=${g(t)} (or label=/id=/role=), or pass an @ref from snapshot.`}function m(e,t){return`${`Selector ${t.selectorExpression} is followed by unexpected extra arguments: "${t.rest.join(` `)}".`} Selector values with spaces need quotes, e.g. ${h(e,t)??`text="Sign in"`}.`}function h(e,t){let n=e.length-t.rest.length,r=e[n-1];if(r===void 0)return;let i=r.indexOf(`=`);if(i<=0)return;let a=[r.slice(i+1),...t.rest].join(` `),o=`${r.slice(0,i+1)}${g(a)}`;return[...e.slice(0,n-1),o].join(` `)}function g(e){return`"${e.replaceAll(`\\`,String.raw`\\`).replaceAll(`"`,String.raw`\"`)}"`}function _(e){return e.join(` `).trim()||void 0}export{c as n,o as r,l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e,O as t,n}from"./sdk-contracts.js";import{
|
|
1
|
+
import{D as e,O as t,n}from"./sdk-contracts.js";import{b as r,d as i}from"./sdk-device.js";import{dn as a}from"./sdk-batch.js";import{C as o,D as s,E as c,M as l,O as u,f as d,i as f,o as p,y as m}from"./session-snapshot.js";import{A as h,M as g,d as _,t as v}from"./parameterized-recorded-fill.js";import{i as y}from"./mobile-snapshot-semantics.js";import{r as b}from"./request-cancel.js";import"./request.js";import{i as x}from"./request-runtime-binding.js";import{n as S}from"./internal/daemon.js";import{i as C,t as w}from"./capture-disclosure.js";function T(e){let{req:t,logPath:n,traceLogPath:r}=e;return{verbose:t.flags?.verbose,logPath:n,traceLogPath:r,requestId:t.meta?.requestId,iosXctestrunFile:t.flags?.iosXctestrunFile,iosXctestDerivedDataPath:t.flags?.iosXctestDerivedDataPath,iosXctestEnvDir:t.flags?.iosXctestEnvDir}}function E(e,t){return!(!e||!i(e.device)||x(e.device)||t.skipPendingPostGestureStabilization&&c(e))}function D(e){let{session:t,selectorExpression:n}=e;return E(t,{skipPendingPostGestureStabilization:!0})?a(n):null}function O(e){let t=e.identifier?.trim();if(t)return{key:`id`,value:t};let n=e.label?.trim();return n?{key:`label`,value:n}:null}async function k(e,t,n){let r=await m(e.device,t,e.appBundleId,n),i=r.found===!0,a=A(r);return{found:i,...typeof r.text==`string`?{text:r.text}:{},...a?{node:a}:{}}}function A(e){let t=e.nodes;if(!Array.isArray(t))return;let n=t[0];if(!(!n||typeof n!=`object`))return n}function j(e,n={}){let r=t(e);if(r.code===`ELEMENT_NOT_FOUND`)return n.delegateSemanticFailures===!0||n.allowElementNotFound===!0;if(r.code===`AMBIGUOUS_MATCH`)return n.delegateSemanticFailures===!0;if(r.code===`ELEMENT_OFFSCREEN`)return n.delegateSemanticFailures!==!1;if(r.code!==`COMMAND_FAILED`)return!1;let i=r.message.toLowerCase();return i.includes(`fetch failed`)||i.includes(`timed out`)||i.includes(`timeout`)||i.includes(`runner did not accept connection`)||i.includes(`invalid runner response`)}async function M(e){let{session:t,node:n,rootViewport:r,requestOptions:i}=e,a=O(n);if(!a)return null;let o;try{o=await k(t,a,i)}catch{return null}if(!o.found||!o.node?.rect)return null;let s={rect:o.node.rect,hittable:o.node.hittable===!0};return y(s,r)?s.rect:null}function N(e){let{operations:t,command:n,positionals:r,actionCommand:i=n,retryPositionals:a,flags:s,result:c,responseData:l,recordedTarget:d,recordedTargets:f,scheduleInteractionOutcomeRetry:p=!0,actionStartedAt:m,actionFinishedAt:h,androidFreshnessBaseline:g}=e,_=u(s),[v,y]=F({command:n,positionals:r,flags:_,result:c,responseData:l}),b=t.isSessionRecording()&&d?o(d):void 0,x=t.isSessionRecording()&&f?P(f):void 0;return t.recordAction({command:n,positionals:r,flags:_??{},result:v,...b?{targetEvidence:b}:{},...x?{targetEvidences:x}:{}}),t.markDeferredOutcome({command:n,action:i,positionals:a??r,flags:s,scheduleOutcomeRetry:p,androidFreshnessBaseline:g}),t.recordGestureVisualization(i,r,v,_??{},m,h),{ok:!0,data:y}}function P(e){let t=o(e.source),n=o(e.destination);return t&&n?{source:t,destination:n}:void 0}function F(e){if(e.command!==`fill`||typeof e.flags?.recordAs!=`string`)return[e.result,e.responseData];let t=h({ts:0,command:`fill`,positionals:e.positionals,flags:e.flags,result:e.result}),n=g(e.flags.recordAs);return[v(e.result,t,n),v(e.responseData,t,n)]}function I(t){let r=t.sessionStore.get(t.sessionName);if(!r)throw new e(`SESSION_NOT_FOUND`,n);return R({requestId:t.req.meta?.requestId,flags:t.req.flags,session:r,contextFromFlags:t.contextFromFlags,captureSnapshot:async(e,n)=>{let i=await t.captureSnapshotForSession(r,e,t.sessionStore,t.contextFromFlags,n);return w(t.activationProof,i)},runtimeSessions:p({sessionName:t.sessionName,getSession:()=>r,recordOptions:{includeSnapshot:!0,omitRefFrameSnapshot:t.req.internal?.findResolvedTarget!==void 0},setRecord:e=>{e.snapshot&&(f(r,e.snapshot),t.sessionStore.set(t.sessionName,r))}}),expireRefFrame:()=>l(r),confirmOffscreenTargetVisible:E(r,{skipPendingPostGestureStabilization:!1})?async(e,n)=>await M({session:r,node:e,rootViewport:n,requestOptions:T({req:t.req,logPath:t.logPath,traceLogPath:r.trace?.outPath})}):void 0,pairedGestureViewport:t.pairedGestureViewport,touchExecutor:t.touchExecutor,gestures:t.gestures})}function L(e){let{session:t,sessionStore:n,...r}=e;return N({...r,operations:{recordAction:n.recordAction.bind(n,t),markDeferredOutcome:e=>s({session:t,...e}),isSessionRecording:_.bind(null,t),recordGestureVisualization:S.bind(null,t)}})}function R(e){return d({backend:z(e),...C(`interaction commands`,{plural:!0}),sessions:e.runtimeSessions,signal:b(e.requestId)})}function z(e){let{flags:t,session:n}=e;return{platform:r(n.device),captureSnapshot:async(n,r)=>({snapshot:await e.captureSnapshot(t,{interactiveOnly:r?.interactiveOnly===!0,preferredBackend:r?.preferredBackend,includeRects:r?.includeRects===!0,signal:n.signal,boundCapture:e.touchExecutor?.captureSnapshot??e.gestures?.captureSnapshot})}),...B(e,()=>e.contextFromFlags(t,n.appBundleId,n.trace?.outPath)),...e.confirmOffscreenTargetVisible?{confirmOffscreenTargetVisible:async(t,n,r)=>await e.confirmOffscreenTargetVisible(n,r)}:{},...V(e.touchExecutor,e.expireRefFrame,t)}}function B(e,t){let n=e.gestures,r=e.pairedGestureViewport;return n?{resolveGestureViewport:async()=>r??await n.gestureViewport?.(t()),performGesture:async(r,i)=>(e.expireRefFrame(),H(await n.performPlan(i,t())))}:r?{resolveGestureViewport:async()=>r}:{}}function V(e,t,n){if(!e)return{};let{tapPoint:r,tapRef:i,fillPoint:a,fillRef:o,longPressPoint:s,hoverPoint:c,hoverRef:l}=e,u=async e=>(t(),H(await e()));return{tap:r?(e,t)=>u(()=>r(t,n)):void 0,tapTarget:i?(e,t)=>u(()=>i(t.ref)):void 0,fill:a?(e,t,n,r)=>u(()=>a(t,n,r)):void 0,fillTarget:o?(e,t,n,r)=>u(()=>o(t.ref,n,r)):void 0,longPress:s?(e,t,n)=>u(()=>s(t,n?.durationMs)):void 0,hover:c?(e,t)=>u(()=>c(t)):void 0,hoverTarget:l?(e,t)=>u(()=>l(t.ref)):void 0}}function H(e){return e&&typeof e==`object`?e:void 0}function U(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}function W(e,t){if(!t||t.settle===!0)return null;let n=[];return t.settleQuietMs!==void 0&&n.push(`--settle-quiet`),n.length===0?null:U(`INVALID_ARGS`,`${e}: ${n.join(`, `)} require${n.length===1?`s`:``} --settle.`)}function G(e){if(e?.settle===!0)return{...e.settleQuietMs===void 0?{}:{quietMs:e.settleQuietMs},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}}}function K(t){try{return q(t),null}catch(t){if(t instanceof e)return U(t.code,t.message,t.details);throw t}}function q(t){let n=t.ref.startsWith(`@`)?t.ref.slice(1):t.ref,{admission:r,scope:i,currentGeneration:a}=t.frame;if(r.admitted)return;let o=r.reason===`plain_ref_requires_complete_frame`&&i!==`all`&&i.has(n)&&a!==void 0?`@${n}~s${a}`:void 0;throw new e(`COMMAND_FAILED`,Y(r.reason,t.ref),{reason:r.reason,ref:t.ref,currentGeneration:a,scope:i===`all`?`all`:Array.from(i),...t.mintedGeneration===void 0?{}:{mintedGeneration:t.mintedGeneration},...o?{suggestedRef:o}:{},hint:o?`Retry with the exact emitted ref ${o}.`:t.staleRefsWarning??J})}const J=`Capture a fresh interactive snapshot (snapshot -i) or use a stable selector, then retry.`;function Y(e,t){switch(e){case`ref_frame_expired`:return`Ref ${t} belongs to an expired ref frame — a device action since the snapshot invalidated it`;case`ref_generation_mismatch`:return`Ref ${t} was minted from a superseded snapshot generation`;case`plain_ref_requires_complete_frame`:return`Ref ${t} needs a complete snapshot — the current frame only authorizes its emitted refs`;case`ref_not_issued`:return`Ref ${t} was not issued by the current ref frame`}}export{I as a,E as c,W as i,D as l,K as n,L as o,G as r,j as s,q as t};
|
package/dist/src/interaction.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,p as t,s as n}from"./session-snapshot.js";import{
|
|
1
|
+
import{i as e,p as t,s as n}from"./session-snapshot.js";import{s as r}from"./quality-warnings.js";import{t as i}from"./backend-snapshot-options.js";import{a,i as o,n as s,o as c,r as l}from"./interaction-ref-policy.js";async function u(e){let{session:t,flags:n,contextFromFlags:a,options:o}=e,s={...n??{},...i(o)},c=a(s,t.appBundleId,t.trace?.outPath),l=await e.capture({flags:s,options:o,context:c});return r(l.snapshotQuality)||e.publishSnapshot(l),l}const d=async(r,i,a,o,s)=>await u({session:r,flags:i,contextFromFlags:o,options:s,capture:async({flags:e,options:i,context:a})=>{let{snapshot:o}=await n({device:r.device,session:r,flags:e,outPath:e.out,logPath:a.logPath??``,includeRects:i.includeRects,androidFreshnessMode:i.androidFreshnessMode,signal:i.signal,...i.boundCapture?{captureData:async()=>await i.boundCapture(t({flags:e,session:r,snapshotScope:e.snapshotScope,includeRects:i.includeRects,signal:i.signal,context:a}))}:{}});return o},publishSnapshot:t=>{e(r,t),a.set(a.resolveStoredSessionName(r),r)}});function f(e){return a({...e,captureSnapshotForSession:e.captureSnapshotForSession??d})}async function p(e){return(await import(`./find.js`)).handleFindCommands(e)}async function m(e){return await(await import(`./interaction2.js`)).handleInteractionCommands({...e,captureSnapshotForSession:e.captureSnapshotForSession??d})}export{d as captureSnapshotForSession,f as createInteractionRuntime,c as finalizeTouchInteraction,p as handleFindCommands,m as handleInteractionCommands,l as readSettleRequest,s as refMutationAdmissionResponse,o as settleFlagGuardResponse};
|