agent-device 0.21.11 → 0.21.13
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.11.apk → agent-device-android-ime-helper-0.21.13.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.13.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.11.manifest.json → agent-device-android-ime-helper-0.21.13.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.11.apk → agent-device-android-snapshot-helper-0.21.13.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.13.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.11.manifest.json → agent-device-android-snapshot-helper-0.21.13.manifest.json} +6 -6
- package/apple/fold-helper/Fold.m +97 -0
- package/apple/macos-helper/Package.swift +3 -6
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/main.swift +3 -8
- package/apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/ScreenshotResponseTests.swift +15 -0
- package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +47 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +99 -42
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/Info.plist +23 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj +17 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAppScreenCapture.swift +21 -13
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerScrollViewportPolicy.swift +1 -162
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +0 -9
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +0 -56
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSystemSurfaceHostPolicy.swift +0 -48
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTapPointPolicy.swift +0 -50
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +22 -568
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +21 -9
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift +0 -36
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandDispatch.swift +630 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +18 -2236
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +1 -338
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Environment.swift +0 -12
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift +165 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +0 -24
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +0 -142
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +90 -39
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+MainThreadWork.swift +78 -106
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +23 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +147 -95
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +0 -209
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +86 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift +287 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +1 -200
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +0 -185
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +75 -285
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotAcquisition.swift +23 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotBackendCapabilities.swift +0 -78
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +83 -578
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCaptureTarget.swift +106 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotExecution.swift +142 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTiming.swift +49 -78
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedCommitDeadline.swift +0 -44
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +27 -97
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +1 -11
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +11 -87
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +2 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +1 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +0 -35
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputCandidatePolicy.swift +0 -31
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +2 -18
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +34 -52
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +0 -22
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TypeExecution.swift +142 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +22 -6
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +140 -20
- package/dist/src/absence-observation-errors.js +1 -1
- package/dist/src/adapter.js +1 -1
- package/dist/src/agent-device-client.js +1 -1
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/android-adb.d.ts +1 -1
- package/dist/src/app-launch.js +2 -2
- package/dist/src/app-log-runtime2.js +3 -3
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/back-mode.js +1 -1
- package/dist/src/capture-disclosure.js +1 -1
- package/dist/src/capture.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +10 -7
- package/dist/src/cli-runner.js +1 -1
- package/dist/src/cli.js +1 -1
- package/dist/src/client-types.d.ts +5 -8
- package/dist/src/code-signature.js +1 -1
- package/dist/src/command-schema.js +3 -3
- package/dist/src/command-tools.js +3 -3
- package/dist/src/connection.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -1
- package/dist/src/daemon-resolution.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-session.js +1 -1
- package/dist/src/devicectl.js +1 -1
- package/dist/src/display-inventory.js +1 -1
- package/dist/src/doctor-facade.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/gesture-plan-types.d.ts +38 -0
- package/dist/src/harmonyos.js +1 -1
- package/dist/src/helper.js +2 -2
- package/dist/src/host.js +1 -1
- package/dist/src/install-source-network-transport.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/interaction-ref-policy.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor-operation-catalog.js +1 -1
- package/dist/src/interactor.js +4 -4
- package/dist/src/interactor2.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +2 -2
- 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/limrun-runtime-dependencies.js +1 -1
- package/dist/src/limrun.d.ts +435 -4
- package/dist/src/linux.js +1 -1
- package/dist/src/local-interactor-operation-set.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 +4 -4
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/perf-facade.js +1 -2
- package/dist/src/perf-runtime-plan.js +1 -1
- package/dist/src/perf-target.js +2 -0
- package/dist/src/physical-device-apps.js +1 -0
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/platform-request-scope.js +1 -1
- package/dist/src/platform-runtime-operation-host.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/provider-webdriver.js +1 -1
- package/dist/src/proxy.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/registry.js +35 -35
- package/dist/src/request-admission.js +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-dev-tools-security.js +1 -1
- package/dist/src/runner-device-readiness.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-error-classification.js +3 -0
- 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 +3 -3
- package/dist/src/runtime10.js +1 -1
- package/dist/src/runtime2.js +2 -2
- 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-runtime.js +1 -1
- package/dist/src/screenshot3.js +1 -1
- package/dist/src/script.js +1 -1
- package/dist/src/scroll-command.d.ts +377 -0
- package/dist/src/scroll-command.js +1 -1
- package/dist/src/sdk-batch.js +2 -2
- package/dist/src/sdk-contracts.d.ts +9 -0
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-selectors.d.ts +23 -715
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/semantic-index.js +1 -1
- package/dist/src/server.js +1 -1
- package/dist/src/session-observation.js +1 -1
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session2.js +2 -2
- package/dist/src/simctl-facade.js +1 -1
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-facade.js +1 -1
- package/dist/src/simulator-state.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-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/src7.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/tool-provider.js +1 -1
- package/dist/src/touch-runtime.js +1 -1
- package/dist/src/tree.js +1 -1
- package/dist/src/update-check.js +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/web2.js +1 -1
- package/package.json +4 -2
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.11.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.11.apk.sha256 +0 -1
- package/apple/macos-helper/Sources/AgentDeviceMacOSDeviceHub/DeviceHubPose.swift +0 -47
- package/apple/macos-helper/Sources/AgentDeviceMacOSDeviceHub/DeviceHubWindowInventory.swift +0 -65
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubPose.swift +0 -225
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubSidebar.swift +0 -57
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubWindowDiscovery.swift +0 -108
- package/apple/macos-helper/Tests/AgentDeviceMacOSDeviceHubTests/DeviceHubPoseTests.swift +0 -30
- package/apple/macos-helper/Tests/AgentDeviceMacOSDeviceHubTests/DeviceHubWindowInventoryTests.swift +0 -65
- package/dist/src/app-inventory.d.ts +0 -4
- package/dist/src/apps-simctl.js +0 -1
- package/dist/src/cloud-artifacts.d.ts +0 -61
- package/dist/src/runner-contract.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { k as Rect } from "./sdk-contracts.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as PointerTrajectorySample, i as PointerTrajectory, o as SinglePointerGesturePlan, r as MultiTouchGesturePlan } from "./gesture-plan-types.js";
|
|
3
3
|
import { Readable, Stream, Writable } from "node:stream";
|
|
4
4
|
//#region packages/platform-android/src/helper-artifacts.d.ts
|
|
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.`)}}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}.`)}}
|
|
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}.`)}}const f=6e4;function p(t){if(t.keyframes===void 0){if(t.pose===void 0)throw new e(`INVALID_ARGS`,`fold requires a pose or keyframes`);if(typeof t.pose!=`string`)throw new e(`INVALID_ARGS`,`fold pose must be a string`);return{pose:d(t.pose)}}if(t.pose!==void 0)throw new e(`INVALID_ARGS`,`fold accepts either pose or keyframes`);return{keyframes:m(t.keyframes)}}function m(t){if(!Array.isArray(t)||t.length<2||t.length>64)throw new e(`INVALID_ARGS`,`fold requires 2–64 keyframes`);let n=t.map(g);if(n[0].atMs!==0||n.some((e,t)=>t>0&&e.atMs<=n[t-1].atMs))throw new e(`INVALID_ARGS`,`Fold keyframes must start at 0ms and increase strictly`);return n}function h(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=t}function g(t){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`Each fold keyframe requires atMs and angle`);let{atMs:n,angle:r}=t;if(Object.keys(t).some(e=>e!==`atMs`&&e!==`angle`))throw new e(`INVALID_ARGS`,`Fold keyframes only accept atMs and angle`);if(!h(n,6e4)||!Number.isSafeInteger(n))throw new e(`INVALID_ARGS`,`Fold keyframe times must be integers from 0 to ${f}ms`);if(!h(r,180))throw new e(`INVALID_ARGS`,`Fold keyframe angles must be finite numbers from 0 to 180`);return{atMs:n,angle:r}}function _(t){let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`--keyframes requires a JSON array of {atMs, angle} objects`)}return m(n)}export{f as a,c,_ as d,d as f,s as i,a as l,n,i as o,o as r,r as s,t,p as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";import{i 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};
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{i 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 setOrientation(e){if(e===`portrait-upside-down`)throw R(`orientation`,`Limrun iOS direct sessions support portrait and landscape orientation, not portrait upside-down.`);await this.session.client.setOrientation(e===`portrait`?`Portrait`:`Landscape`)}async setSetting(){throw R(`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`)}function R(t,n){throw new e(`UNSUPPORTED_OPERATION`,n,{command:t})}function z(e){return e.platform===`android`?B(e):V(e)}function B(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),...H(e.client,e.token,e.dependencies.host),installRemoteApp:async t=>{await e.client.sendAsset(t)}}}function V(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),...H(e.client,e.token,e.dependencies.host),installRemoteApp:async(t,n)=>await D(e,t,n),runSimctl:t=>e.client.simctl(t)}}function H(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,z as t};
|
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:O(c,l)??`Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.`}))}async function u(e,t){return C(x(await g(e,{jsonPrefix:`agent-device-ios-apps`,args:[`devicectl`,`device`,`info`,`apps`,`--device`,e.id,`--include-all-apps`],failureMessage:`Failed to list iOS apps`,parseFailureMessage:`Failed to parse iOS apps list`})),t)}async function d(t){let n=await g(t,{jsonPrefix:`agent-device-ios-processes`,args:[`devicectl`,`device`,`info`,`processes`,`--device`,t.id],failureMessage:`Failed to list iOS processes`,parseFailureMessage:`Failed to parse iOS process list`,fallbackHint:T});if(!y(n))throw new e(`COMMAND_FAILED`,`Unsupported iOS process list response`,{deviceId:t.id,hint:T});return S(n)}async function f(e,t){let{appBundleUrl:n,processes:r}=await p(e,t),i=r.sort((e,t)=>v(e,n)-v(t,n))[0];i&&await g(e,{jsonPrefix:`agent-device-ios-process-terminate`,args:[`devicectl`,`device`,`process`,`terminate`,`--device`,e.id,`--pid`,String(i.pid),`--kill`],failureMessage:`Failed to terminate iOS app`,parseFailureMessage:`Failed to parse iOS process termination response`,tolerateFailurePayload:b})}async function p(t,n){let r=(await u(t,`all`)).find(e=>e.bundleId===n);if(!r)throw new e(`APP_NOT_INSTALLED`,`No iOS device app found for ${n}`,{appBundleId:n,deviceId:t.id});if(!r.url)throw new e(`COMMAND_FAILED`,`Missing app bundle URL for ${n}`,{appBundleId:n,deviceId:t.id,hint:`Installed-app metadata from devicectl did not include the bundle URL required to match running processes. Use an Xcode/CoreDevice toolchain that reports app URLs.`});let i=r.url.replace(/\/+$/,``);return{appBundleUrl:i,processes:(await d(t)).filter(e=>e.executable.startsWith(`${i}/`))}}async function m(e){let n=c.join(i(),`${e.jsonPrefix}-${t()}-${Date.now()}-${Math.random().toString(36).slice(2)}.json`),a=[...e.args,`--json-output`,n];try{let t=await s(a,{allowFailure:!0,signal:e.signal,timeoutMs:e.timeoutMs??2e4});if(t.exitCode!==0){let r=await _(n).catch(()=>void 0);return r!==void 0&&e.tolerateFailurePayload?.(r)?{ok:!0,payload:r}:{ok:!1,reason:`command-failed`,args:a,result:t,payload:r}}return await h(n,a,t)}finally{await r(n).catch(()=>{})}}async function h(t,n,r){try{return{ok:!0,payload:await _(t)}}catch(t){if(t instanceof e)throw t;return{ok:!1,reason:`unreadable-json`,args:n,result:r,cause:String(t)}}}async function g(t,r){let i=await m(r);if(i.ok)return i.payload;if(i.reason===`command-failed`){let{stdout:a,stderr:o}=i.result;throw new e(`COMMAND_FAILED`,r.failureMessage,n(i.result,{cmd:`xcrun`,args:i.args,stdout:a,stderr:o,deviceId:t.id,hint:O(a,o)??r.fallbackHint??`Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.`}))}throw new e(`COMMAND_FAILED`,r.parseFailureMessage,{deviceId:t.id,cause:i.cause})}async function _(e){return JSON.parse(await a(e))}function v(e,t){return e.executable.slice(t.length+1).split(`/`).length}function y(e){return Array.isArray(e?.result?.runningProcesses)}function b(e){let t=e?.error?.userInfo?.NSUnderlyingError?.error;return t?.domain===`NSPOSIXErrorDomain`&&t.code===3}function x(e){let t=e?.result?.apps;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=typeof e.bundleIdentifier==`string`?e.bundleIdentifier.trim():``;if(!t)continue;let r=typeof e.name==`string`&&e.name.trim().length>0?e.name.trim():t,i=typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():void 0;n.push({bundleId:t,name:r,url:i})}return n}function S(e){let t=e?.result?.runningProcesses;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=typeof e.executable==`string`?e.executable.trim():``,r=typeof e.processIdentifier==`number`&&Number.isFinite(e.processIdentifier)?e.processIdentifier:NaN;!t||!Number.isFinite(r)||n.push({executable:t,pid:r})}return n}function C(e,t){return o(e,t)}const w=`Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.`,T=`This Xcode/CoreDevice toolchain must support 'devicectl device info processes' with JSON runningProcesses so agent-device can resolve app process IDs. Inspect diagnostics for the exact devicectl API failure.`,E=`Enable Developer Mode on the iOS device (Settings > Privacy & Security > Developer Mode), restart it when prompted, unlock it, then retry.`,D=`Let Xcode finish preparing this device: keep it unlocked and connected by cable, open Xcode > Settings > Platforms (or Window > Devices and Simulators), wait for device support to install, then retry.`;function O(e,t){let n=`${e}\n${t}`.toLowerCase();return n.includes(`device is busy`)&&n.includes(`connecting`)?`iOS device is still connecting. Keep it unlocked and connected by cable until it is fully available in Xcode Devices, then retry.`:n.includes(`coredeviceservice`)&&n.includes(`timed out`)?`CoreDevice service timed out. Reconnect the device and retry; if it persists restart Xcode and the iOS device.`:n.includes(`developer mode is disabled`)?E:n.includes(`developer disk image`)?D:n.includes(`must be paired`)?`Pair the iOS device with this Mac: connect it by cable, unlock it, accept the Trust prompt, and enter the device passcode, then retry.`:null}export{p as a,m as c,u as i,f as l,D as n,O as o,E as r,l as s,w as t};
|
|
@@ -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{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
|
|
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.stderr.trim()),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{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
|
|
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{a as r}from"./runner-client.js";import{O as i}from"./runner-disposal.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 i(n)?{id:`ios-runner-cache`,status:`pass`,summary:`iOS runner artifact cached; first open skips the runner build`}:(r(n,{}),a.emitProgress(`Warming iOS runner build cache in the background (${n.name})...`),{id:`ios-runner-cache`,status:`pass`,summary:`iOS runner build started in the background; the first open gets faster once it completes`,hint:"Run `agent-device prepare ios-runner` to wait for a fully warmed runner instead."})}function s(e){return{id:`toolchain`,status:c(e),summary:l(e),evidence:{selectedPath:e.selectedPath??null,xcodeVersion:e.versionLine??null}}}function c(e){return e.versionLine?`pass`:`info`}function l(e){return e.versionLine?e.selectedPath?`Apple toolchain: ${e.versionLine}; xcode-select ${e.selectedPath}.`:`Apple toolchain: ${e.versionLine}; xcode-select path unavailable.`:`Apple toolchain: xcodebuild version check failed.`}function u(){return{id:`toolchain`,status:`info`,summary:`Apple toolchain: xcodebuild version check failed.`,hint:`Install/select Xcode and complete first launch/license setup if xcodebuild reports it.`,command:`xcodebuild -version`}}export{o as appleRunnerWarmupCheck,a as appleToolchainCheck};
|
package/dist/src/find.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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{
|
|
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{I as u,P as d,z 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{p 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 e}}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;f(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],u(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`);f(o);let l=n.boundFocusPoint;return l?{ok:!0,data:await S({operations:{focusPoint:l}},c,u(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};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { D as Point, k as Rect } from "./sdk-contracts.js";
|
|
2
|
+
//#region packages/contracts/src/app-inventory.d.ts
|
|
3
|
+
type AppsFilter = 'user-installed' | 'all';
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region packages/contracts/src/gesture-plan-types.d.ts
|
|
6
|
+
type GesturePointerCount = 1 | 2;
|
|
7
|
+
/** Selects one-pointer release timing without changing semantic gesture intent. */
|
|
8
|
+
type GestureExecutionProfile = 'endpoint-hold' | 'timed-pan';
|
|
9
|
+
type PointerTrajectorySample = {
|
|
10
|
+
offsetMs: number;
|
|
11
|
+
point: Point;
|
|
12
|
+
};
|
|
13
|
+
type PointerTrajectory = {
|
|
14
|
+
pointerId: 0 | 1;
|
|
15
|
+
samples: readonly PointerTrajectorySample[];
|
|
16
|
+
};
|
|
17
|
+
type SinglePointerTrajectory = {
|
|
18
|
+
pointerId: 0;
|
|
19
|
+
samples: readonly [PointerTrajectorySample, PointerTrajectorySample, ...PointerTrajectorySample[]];
|
|
20
|
+
};
|
|
21
|
+
type SinglePointerGesturePlan = {
|
|
22
|
+
topology: 'single';
|
|
23
|
+
intent: 'fling' | 'pan';
|
|
24
|
+
executionProfile: GestureExecutionProfile;
|
|
25
|
+
durationMs: number;
|
|
26
|
+
viewport: Rect;
|
|
27
|
+
pointers: readonly [SinglePointerTrajectory];
|
|
28
|
+
};
|
|
29
|
+
type MultiTouchGesturePlan = {
|
|
30
|
+
topology: 'two';
|
|
31
|
+
intent: 'pan' | 'pinch' | 'rotate' | 'transform';
|
|
32
|
+
durationMs: number;
|
|
33
|
+
viewport: Rect;
|
|
34
|
+
pointers: readonly [PointerTrajectory, PointerTrajectory];
|
|
35
|
+
};
|
|
36
|
+
type GesturePlan = SinglePointerGesturePlan | MultiTouchGesturePlan;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { PointerTrajectorySample as a, PointerTrajectory as i, GesturePointerCount as n, SinglePointerGesturePlan as o, MultiTouchGesturePlan as r, AppsFilter as s, GesturePlan 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),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)
|
|
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)}}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({macOsClickScheduleMs:()=>X,quitMacOsApp:()=>G,resolveFrontmostMacOsApp:()=>W,resolveMacOsHelperPackageRootFrom:()=>M,runMacOsAlertAction:()=>q,
|
|
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
|
|
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,runMacOsPermissionAction:()=>K,runMacOsPressAction:()=>Z,runMacOsReadTextAction:()=>Y,runMacOsScreenshotAction:()=>Q,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,t={}){let n=[`screenshot`,`--out`,e];return j(n,t),await U(n)}export{K as a,q as i,G as n,Q as o,W as r,V as s,w as t};
|
package/dist/src/host.js
CHANGED
|
@@ -1 +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.
|
|
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. Production binds it in core/runner-client.ts; package tests bind it through runner/test-host.ts.`);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{a as e,t}from"./rolldown-runtime.js";import{D as n,F as r,k as i}from"./sdk-contracts.js";import{t as a}from"./undici.js";import o from"node:net";import s from"node:dns/promises";var c=e(t(((e,t)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>=t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(t[e].length>4?NaN:parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,"toString",{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>4294967295||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t;for(t=0;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}return(t=e.match(r.twoOctet))?(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>16777215||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})():(t=e.match(r.threeOctet))?(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})():null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=``;this.zoneId&&(t=`%${this.zoneId}`);let n=this.toNormalizedString(),r=n.slice(0,n.length-t.length),i=0,a=-1,o=-1,s;for(;s=e.exec(r);){let e=(s[0].match(/0/g)||[]).length;e>o&&(o=e,i=s.index,a=s[0].length)}return a<0?r+t:`${r.substring(0,i)}::${r.substring(i+a)}${t}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t&&t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch(e){throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`,{cause:e})}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(e)}))(),1);async function l(e,t){if(e.protocol!==`http:`&&e.protocol!==`https:`)throw new n(`INVALID_ARGS`,`Unsupported source URL protocol: ${e.protocol}`);if(e.username||e.password)throw new n(`INVALID_ARGS`,`Source URL credentials are not allowed`);d(t);let i=h(e.hostname);p(i)&&_(e.hostname);let a=o.isIP(i);if(a)return{address:i,family:a};let s;try{s=await u(i,t)}catch(e){throw r(e)?e:new n(`INVALID_ARGS`,`Source URL host could not be resolved: ${i}`,{hint:`Use a public artifact URL.`},e)}if(s.length===0)throw new n(`INVALID_ARGS`,`Source URL host could not be resolved: ${i}`,{hint:`Use a public artifact URL.`});s.some(e=>m(e.address))&&_(i);let c=s[0];return{address:c.address,family:c.family}}async function u(e,t){let n=s.lookup(e,{all:!0,verbatim:!0});return t?await new Promise((e,r)=>{let i=()=>r(f(t.reason));t.addEventListener(`abort`,i,{once:!0}),n.then(e,r).finally(()=>t.removeEventListener(`abort`,i))}):await n}function d(e){if(e?.aborted)throw f(e.reason)}function f(e){return i(void 0,e)}function p(e){let t;try{t=h(e)}catch{return!0}return!t||t===`localhost`||t.endsWith(`.localhost`)?!0:o.isIP(t)!==0&&m(t)}function m(e){try{return c.default.process(g(e)).range()!==`unicast`}catch{return!0}}function h(e){let t=g(e).toLowerCase().replace(/\.$/,``);if(!t||t.includes(`%`))throw new n(`INVALID_ARGS`,`Source URL host is not allowed`,{hint:`Use a public artifact URL.`});return t}function g(e){return e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e}function _(e){throw new n(`INVALID_ARGS`,`Source URL host is not allowed because it resolves to a non-public address: ${e}`,{hint:`Use a public artifact URL.`})}var v=a();async function y(e){let t=b(e.url),n=t?C(t,e.url):S(e.approvedAddress,e.family),r=t?w(e.url,e.approvedAddress,e.family):e.url;try{let i={dispatcher:n,headers:t?{...e.headers,host:e.url.host}:e.headers,maxRedirections:0,method:`GET`,signal:e.signal},a=await(0,v.request)(r,i);return{statusCode:a.statusCode,headers:a.headers,body:a.body,close:async()=>await D(n)}}catch(e){throw await D(n),e}}function b(e,t=process.env){if(x(e,t.no_proxy??t.NO_PROXY))return;let n=t.http_proxy??t.HTTP_PROXY;return e.protocol===`http:`?n||void 0:(t.https_proxy??t.HTTPS_PROXY)||n||void 0}function x(e,t){if(!t)return!1;let n=E(e.hostname).toLowerCase(),r=e.port||(e.protocol===`https:`?`443`:`80`);return t.split(/[\s,]+/).filter(Boolean).some(e=>{if(e===`*`)return!0;let t=T(e);if(t.port&&t.port!==r)return!1;let i=t.hostname.replace(/^\*?\./,``).toLowerCase();return n===i||n.endsWith(`.${i}`)})}function S(e,t){return new v.Agent({connect:{lookup:(n,r,i)=>i(null,e,t)}})}function C(e,t){let n=o.isIP(E(t.hostname))!==0;return new v.ProxyAgent({uri:e,proxyTunnel:!0,requestTls:t.protocol===`https:`&&!n?{servername:E(t.hostname)}:void 0})}function w(e,t,n){let r=new URL(e);return r.hostname=n===6?`[${E(t)}]`:t,r}function T(e){if(e.startsWith(`[`)){let t=e.indexOf(`]`);return t<0?{hostname:e}:{hostname:e.slice(1,t),port:e[t+1]===`:`?e.slice(t+2):void 0}}let t=e.lastIndexOf(`:`);return t>-1&&e.indexOf(`:`)===t?{hostname:e.slice(0,t),port:e.slice(t+1)}:{hostname:e}}function E(e){return e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e}async function D(e){await e.close()}export{b as n,l as r,y as t};
|
|
1
|
+
import{a as e,t}from"./rolldown-runtime.js";import{D as n,F as r,k as i}from"./sdk-contracts.js";import{t as a}from"./undici.js";import o from"node:net";import s from"node:dns/promises";var c=e(t(((e,t)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>=t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(t[e].length>4?NaN:parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,"toString",{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>4294967295||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t;for(t=0;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}return(t=e.match(r.twoOctet))?(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>16777215||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})():(t=e.match(r.threeOctet))?(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})():null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=``;this.zoneId&&(t=`%${this.zoneId}`);let n=this.toNormalizedString(),r=n.slice(0,n.length-t.length),i=0,a=-1,o=-1,s;for(;s=e.exec(r);){let e=(s[0].match(/0/g)||[]).length;e>o&&(o=e,i=s.index,a=s[0].length)}return a<0?r+t:`${r.substring(0,i)}::${r.substring(i+a)}${t}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t&&t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch(e){throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`,{cause:e})}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(e)}))(),1);async function l(e,t){if(e.protocol!==`http:`&&e.protocol!==`https:`)throw new n(`INVALID_ARGS`,`Unsupported source URL protocol: ${e.protocol}`);if(e.username||e.password)throw new n(`INVALID_ARGS`,`Source URL credentials are not allowed`);d(t);let i=h(e.hostname);p(i)&&_(e.hostname);let a=o.isIP(i);if(a)return{address:i,family:a};let s;try{s=await u(i,t)}catch(e){throw r(e)?e:new n(`INVALID_ARGS`,`Source URL host could not be resolved: ${i}`,{hint:`Use a public artifact URL.`},e)}if(s.length===0)throw new n(`INVALID_ARGS`,`Source URL host could not be resolved: ${i}`,{hint:`Use a public artifact URL.`});s.some(e=>m(e.address))&&_(i);let c=s[0];return{address:c.address,family:c.family}}async function u(e,t){let n=s.lookup(e,{all:!0,verbatim:!0});return t?await new Promise((e,r)=>{let i=()=>r(f(t.reason));t.addEventListener(`abort`,i,{once:!0}),n.then(e,r).finally(()=>t.removeEventListener(`abort`,i))}):await n}function d(e){if(e?.aborted)throw f(e.reason)}function f(e){return i(void 0,e)}function p(e){let t;try{t=h(e)}catch{return!0}return!t||t===`localhost`||t.endsWith(`.localhost`)?!0:o.isIP(t)!==0&&m(t)}function m(e){try{return c.default.process(g(e)).range()!==`unicast`}catch{return!0}}function h(e){let t=g(e).toLowerCase().replace(/\.$/,``);if(!t||t.includes(`%`))throw new n(`INVALID_ARGS`,`Source URL host is not allowed`,{hint:`Use a public artifact URL.`});return t}function g(e){return e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e}function _(e){throw new n(`INVALID_ARGS`,`Source URL host is not allowed because it resolves to a non-public address: ${e}`,{hint:`Use a public artifact URL.`})}var v=a();async function y(e){let t=b(e.url),n=t?C(t,e.url):S(e.approvedAddress,e.family),r=t?w(e.url,e.approvedAddress,e.family):e.url;try{let i={dispatcher:n,headers:t?{...e.headers,host:e.url.host}:e.headers,maxRedirections:0,method:`GET`,signal:e.signal},a=await(0,v.request)(r,i);return{statusCode:a.statusCode,headers:a.headers,body:a.body,close:async()=>await D(n)}}catch(e){throw await D(n),e}}function b(e,t=process.env){if(x(e,t.no_proxy??t.NO_PROXY))return;let n=t.http_proxy??t.HTTP_PROXY;return e.protocol===`http:`?n||void 0:(t.https_proxy??t.HTTPS_PROXY)||n||void 0}function x(e,t){if(!t)return!1;let n=E(e.hostname).toLowerCase(),r=e.port||(e.protocol===`https:`?`443`:`80`);return t.split(/[\s,]+/).filter(Boolean).some(e=>{if(e===`*`)return!0;let t=T(e);if(t.port&&t.port!==r)return!1;let i=t.hostname.replace(/^\*?\./,``).toLowerCase();return n===i||n.endsWith(`.${i}`)})}function S(e,t){return new v.Agent({connect:{lookup:(n,r,i)=>{if(r.all){i(null,[{address:e,family:t}]);return}i(null,e,t)}}})}function C(e,t){let n=o.isIP(E(t.hostname))!==0;return new v.ProxyAgent({uri:e,proxyTunnel:!0,requestTls:t.protocol===`https:`&&!n?{servername:E(t.hostname)}:void 0})}function w(e,t,n){let r=new URL(e);return r.hostname=n===6?`[${E(t)}]`:t,r}function T(e){if(e.startsWith(`[`)){let t=e.indexOf(`]`);return t<0?{hostname:e}:{hostname:e.slice(1,t),port:e[t+1]===`:`?e.slice(t+2):void 0}}let t=e.lastIndexOf(`:`);return t>-1&&e.indexOf(`:`)===t?{hostname:e.slice(0,t),port:e.slice(t+1)}:{hostname:e}}function E(e){return e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e}async function D(e){await e.close()}export{b as n,l as r,y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e,k as t}from"./sdk-contracts.js";import{t as n}from"./path-resolution.js";import"./file.js";import{a as r,i,n as a,r as o}from"./archive.js";import{t as s}from"./byte-limit-stream.js";import{r as c,t as l}from"./install-source-network-transport.js";import u from"node:path";import{createWriteStream as d,promises as f}from"node:fs";import{AsyncLocalStorage as p}from"node:async_hooks";import m from"node:os";import{pipeline as h}from"node:stream/promises";async function g(t,n){let r=await f.stat(t).catch(()=>null);if(!r)throw new e(`INVALID_ARGS`,`App source not found: ${t}`);if(n.isInstallablePath(t,r))return{archivePath:n.archivePath,installablePath:t};if(r.isFile()&&x(t))return b(t,n,!1),await _(t,n);if(r.isDirectory()){let r=await y(t,n.isInstallablePath);if(r.length===1)return{archivePath:n.archivePath,installablePath:r[0]};if(r.length>1)throw new e(`INVALID_ARGS`,`Found multiple ${n.installableLabel} candidates under ${t}: ${r.join(`, `)}`,{matches:r});let i=await y(t,(e,t)=>!!(t.isFile()&&x(e)));if(i.length===1)return b(i[0],n,!0),await _(i[0],n);if(i.length>1)throw new e(`INVALID_ARGS`,`Found multiple nested archives under ${t}; expected one ${n.installableLabel} source`,{matches:i})}throw new e(`INVALID_ARGS`,`Expected ${n.installableLabel} source, but got ${t}`)}async function _(e,t){let n=await v(e,t.budget,t.archiveDepth+1);return t.onArchiveAccepted?.(t.archiveDepth+1),t.registerCleanup(n.cleanup),await g(n.outputPath,{...t,archivePath:t.archivePath??e,archiveDepth:t.archiveDepth+1})}async function v(t,n,r){let i=a(t);if(!i)throw new e(`INVALID_ARGS`,`Unsupported archive: ${t}`);let s=await f.mkdtemp(u.join(m.tmpdir(),`agent-device-archive-`)),c=u.join(s,`extracted`);try{return await o({archivePath:t,outputRoot:c,type:i,budget:n,depth:r}),{outputPath:c,cleanup:async()=>await f.rm(s,{recursive:!0,force:!0})}}catch(e){throw await f.rm(s,{recursive:!0,force:!0}),e}}async function y(e,t){let n=[],r=[{path:e,depth:0}];for(;r.length>0;){let e=r.shift();if(!e)continue;let i=await f.readdir(e.path,{withFileTypes:!0});i.sort((e,t)=>e.name.localeCompare(t.name));for(let a of i){if(a.name===`__MACOSX`||a.name.startsWith(`._`))continue;let i=u.join(e.path,a.name);t(i,a)?n.push(i):a.isDirectory()&&e.depth<5&&r.push({path:i,depth:e.depth+1})}}return[...new Set(n)]}function b(t,n,r){if(n.allowArchiveExtraction)return;let i=r?`URL sources must point directly to a ${n.installableLabel}; nested archives are not allowed`:`URL sources must point directly to a ${n.installableLabel}; archive extraction is not allowed`;throw new e(`INVALID_ARGS`,i,{path:t})}function x(e){return a(e)!==void 0}const S=new p;async function C(e){return await S.run({budget:new i,depth:0},e)}function w(){return S.getStore()?.budget}function T(){return S.getStore()?.depth??0}function E(e){let t=S.getStore();t&&(t.depth=Math.max(t.depth,e))}const D=new Set([301,302,303,307,308]),O=new Set([`accept-encoding`,`connection`,`content-length`,`host`,`keep-alive`,`proxy-connection`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`]);async function
|
|
1
|
+
import{D as e,k as t}from"./sdk-contracts.js";import{t as n}from"./path-resolution.js";import"./file.js";import{a as r,i,n as a,r as o}from"./archive.js";import{t as s}from"./byte-limit-stream.js";import{r as c,t as l}from"./install-source-network-transport.js";import u from"node:path";import{createWriteStream as d,promises as f}from"node:fs";import{AsyncLocalStorage as p}from"node:async_hooks";import m from"node:os";import{pipeline as h}from"node:stream/promises";async function g(t,n){let r=await f.stat(t).catch(()=>null);if(!r)throw new e(`INVALID_ARGS`,`App source not found: ${t}`);if(n.isInstallablePath(t,r))return{archivePath:n.archivePath,installablePath:t};if(r.isFile()&&x(t))return b(t,n,!1),await _(t,n);if(r.isDirectory()){let r=await y(t,n.isInstallablePath);if(r.length===1)return{archivePath:n.archivePath,installablePath:r[0]};if(r.length>1)throw new e(`INVALID_ARGS`,`Found multiple ${n.installableLabel} candidates under ${t}: ${r.join(`, `)}`,{matches:r});let i=await y(t,(e,t)=>!!(t.isFile()&&x(e)));if(i.length===1)return b(i[0],n,!0),await _(i[0],n);if(i.length>1)throw new e(`INVALID_ARGS`,`Found multiple nested archives under ${t}; expected one ${n.installableLabel} source`,{matches:i})}throw new e(`INVALID_ARGS`,`Expected ${n.installableLabel} source, but got ${t}`)}async function _(e,t){let n=await v(e,t.budget,t.archiveDepth+1);return t.onArchiveAccepted?.(t.archiveDepth+1),t.registerCleanup(n.cleanup),await g(n.outputPath,{...t,archivePath:t.archivePath??e,archiveDepth:t.archiveDepth+1})}async function v(t,n,r){let i=a(t);if(!i)throw new e(`INVALID_ARGS`,`Unsupported archive: ${t}`);let s=await f.mkdtemp(u.join(m.tmpdir(),`agent-device-archive-`)),c=u.join(s,`extracted`);try{return await o({archivePath:t,outputRoot:c,type:i,budget:n,depth:r}),{outputPath:c,cleanup:async()=>await f.rm(s,{recursive:!0,force:!0})}}catch(e){throw await f.rm(s,{recursive:!0,force:!0}),e}}async function y(e,t){let n=[],r=[{path:e,depth:0}];for(;r.length>0;){let e=r.shift();if(!e)continue;let i=await f.readdir(e.path,{withFileTypes:!0});i.sort((e,t)=>e.name.localeCompare(t.name));for(let a of i){if(a.name===`__MACOSX`||a.name.startsWith(`._`))continue;let i=u.join(e.path,a.name);t(i,a)?n.push(i):a.isDirectory()&&e.depth<5&&r.push({path:i,depth:e.depth+1})}}return[...new Set(n)]}function b(t,n,r){if(n.allowArchiveExtraction)return;let i=r?`URL sources must point directly to a ${n.installableLabel}; nested archives are not allowed`:`URL sources must point directly to a ${n.installableLabel}; archive extraction is not allowed`;throw new e(`INVALID_ARGS`,i,{path:t})}function x(e){return a(e)!==void 0}const S=new p;async function C(e){return await S.run({budget:new i,depth:0},e)}function w(){return S.getStore()?.budget}function T(){return S.getStore()?.depth??0}function E(e){let t=S.getStore();t&&(t.depth=Math.max(t.depth,e))}const D=new Set([301,302,303,307,308]),O=/^[A-Z][A-Z0-9_]{0,63}$/,k=new Set([`accept-encoding`,`connection`,`content-length`,`host`,`keep-alive`,`proxy-connection`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`]);async function A(e){let t=V(e.url),n=L(e.headers);for(let r=0;;r+=1){let i=await j(t,n,e.signal);try{let a=N(i,t,r);if(a){a.origin!==t.origin&&(n=R(n)),t=a;continue}return P(i),await F(e.tempDir,t,i)}finally{await i.close()}}}async function j(t,n,r){let i=await c(t,r);try{return await l({url:t,approvedAddress:i.address,family:i.family,headers:{...n,"accept-encoding":`identity`},signal:r})}catch(t){if(t instanceof e)throw t;let n=M(t);throw new e(`COMMAND_FAILED`,n?`The daemon failed to fetch the app source (network error code: ${n})`:`The daemon failed to fetch the app source`,n?{networkErrorCode:n}:void 0,t)}}function M(e){let t=e?.code;return typeof t==`string`&&O.test(t)?t:void 0}function N(t,n,r){if(!D.has(t.statusCode))return;t.body.resume?.();let i=B(t.headers,`location`);if(!i||r>=5)throw new e(`COMMAND_FAILED`,`App source redirect limit was exceeded`,{status:t.statusCode});let a=new URL(i,n);if(n.protocol===`https:`&&a.protocol!==`https:`)throw new e(`COMMAND_FAILED`,`App source redirect downgraded HTTPS`);return a}function P(t){if(!(t.statusCode>=200&&t.statusCode<300))throw new e(`COMMAND_FAILED`,`Failed to download app source: ${t.statusCode}`,{status:t.statusCode})}async function F(t,n,i){let a=B(i.headers,`content-encoding`);if(a&&a.toLowerCase()!==`identity`)throw new e(`COMMAND_FAILED`,`App source response used unsupported content encoding`);I(B(i.headers,`content-length`));let o=u.join(t,z(i,n)),c=s({maxBytes:r,createLimitError:()=>new e(`COMMAND_FAILED`,`App source exceeds maximum size of ${r} bytes`,{reason:`ARTIFACT_BYTE_LIMIT`})});try{return await h(i.body,c,d(o,{flags:`wx`})),o}catch(e){throw await f.rm(o,{force:!0}).catch(()=>{}),e}}function I(t){if(t===null)return;if(!/^\d+$/.test(t))throw new e(`COMMAND_FAILED`,`App source response had invalid content-length`);let n=Number(t);if(!Number.isSafeInteger(n)||n>2147483648)throw new e(`COMMAND_FAILED`,`App source response exceeded the byte limit`,{reason:`ARTIFACT_BYTE_LIMIT`})}function L(e){let t=new Set(Object.entries(e??{}).filter(([e])=>e.toLowerCase()===`connection`).flatMap(([,e])=>e.split(`,`).map(e=>e.trim().toLowerCase())));return Object.fromEntries(Object.entries(e??{}).filter(([e])=>{let n=e.toLowerCase();return!k.has(n)&&!t.has(n)}))}function R(e){return Object.fromEntries(Object.entries(e).filter(([e])=>[`accept`,`user-agent`].includes(e.toLowerCase())))}function z(e,t){let n=(B(e.headers,`content-disposition`)?.match(/filename\*?=(?:UTF-8'')?"?([^";]+)"?/i))?.[1]?.trim()||u.basename(t.pathname)||`downloaded-artifact.bin`;return u.basename(n)}function B(e,t){let n=e[t];return Array.isArray(n)?n[0]??null:n??null}function V(t){let n;try{n=new URL(t)}catch{throw new e(`INVALID_ARGS`,`Invalid source URL`)}if(n.username||n.password)throw new e(`INVALID_ARGS`,`Source URL credentials are not allowed`);return n}const H=Object.freeze([`.zip`,`.tar`,`.tar.gz`,`.tgz`]);async function U(e){let t=[];try{let n=await G(e.source,{signal:e.signal,downloadTimeoutMs:e.downloadTimeoutMs});t.push(n.cleanup);let r=await g(n.localPath,{archivePath:void 0,isInstallablePath:e.isInstallablePath,installableLabel:e.installableLabel,allowArchiveExtraction:e.allowArchiveExtraction!==!1,registerCleanup:e=>{t.push(e)},budget:w()??new i,archiveDepth:0,onArchiveAccepted:E});return{archivePath:r.archivePath,installablePath:r.installablePath,cleanup:async()=>{await Q(t)}}}catch(e){throw await Q(t),e}}function W(e){return n(e)}async function G(e,t){if(e.kind===`path`)return{localPath:W(e.path),cleanup:async()=>{}};let n=await f.mkdtemp(u.join(m.tmpdir(),`agent-device-source-`));try{return{localPath:await K(n,e.url,e.headers,t),cleanup:async()=>{await f.rm(n,{recursive:!0,force:!0})}}}catch(e){throw await f.rm(n,{recursive:!0,force:!0}),e}}async function K(e,n,r,i){let a=i?.signal;if(a?.aborted)throw t();let o=i?.downloadTimeoutMs??12e4,s=AbortSignal.timeout(o),c=a?AbortSignal.any([a,s]):s;try{return await A({tempDir:e,url:n,headers:r,signal:c})}catch(e){throw q(e,a,s,o)}}function q(n,r,i,a){return r?.aborted?t(void 0,n):i.aborted?new e(`COMMAND_FAILED`,`App source download timed out after ${a}ms`,{timeoutMs:a},n):n}async function J(e){await c(e)}function Y(e){let t=e instanceof URL?e:new URL(e),n=t.hostname.toLowerCase();if(!n)return!1;let r=t.pathname;return X(n,r)||Z(n,r)}function X(e,t){return e===`api.github.com`?/^\/repos\/[^/]+\/[^/]+\/actions\/artifacts\/\d+\/zip$/i.test(t):e===`github.com`&&/^\/[^/]+\/[^/]+\/(?:actions\/runs\/\d+\/artifacts\/\d+|suites\/\d+\/artifacts\/\d+)$/i.test(t)}function Z(e,t){return e!==`expo.dev`&&!e.endsWith(`.expo.dev`)?!1:/^\/(?:artifacts\/eas\/|accounts\/[^/]+\/projects\/[^/]+\/builds\/)/i.test(t)}async function Q(e){for(let t of[...e].reverse())await t()}export{w as a,C as c,J as i,Y as n,T as o,U as r,E as s,H as t};
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,P as l,f as u,i as d,o as f,y as p,z 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 p(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:u,recordedTarget:d,recordedTargets:f,scheduleInteractionOutcomeRetry:p=!0,actionStartedAt:m,actionFinishedAt:h,androidFreshnessBaseline:g}=e,_=l(s),[v,y]=F({command:n,positionals:r,flags:_,result:c,responseData:u}),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:f({sessionName:t.sessionName,getSession:()=>r,recordOptions:{includeSnapshot:!0,omitRefFrameSnapshot:t.req.internal?.findResolvedTarget!==void 0},setRecord:e=>{e.snapshot&&(d(r,e.snapshot),t.sessionStore.set(t.sessionName,r))}}),expireRefFrame:()=>m(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 u({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};
|