agent-device 0.19.2 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -70
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.0.apk +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.0.apk.sha256 +1 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.0.manifest.json +10 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.0.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.0.apk.sha256 +1 -0
- package/{android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.19.2.manifest.json → android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.0.manifest.json} +6 -6
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +2 -0
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +5 -0
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +12 -10
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +154 -185
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +113 -19
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift +82 -0
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +275 -113
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +2 -2
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +150 -104
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +56 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+LifecycleCacheTests.swift +73 -0
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +44 -14
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +2 -2
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +2 -106
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +126 -11
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +51 -8
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTraversalIdentityTests.swift +24 -0
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +1 -1
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +43 -35
- package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +14 -0
- package/dist/src/agent-browser-tool.js +1 -1
- package/dist/src/agent-device-client.js +3 -0
- package/dist/src/android-adb.d.ts +1 -1
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android-input-method-overlays.js +1 -0
- package/dist/src/android-input-ownership.js +1 -6
- package/dist/src/android-system-chrome.js +1 -0
- package/dist/src/android.js +1 -1
- package/dist/src/app-lifecycle.js +5 -5
- package/dist/src/app-log-request-scope.js +1 -0
- package/dist/src/app-resolution.js +1 -0
- package/dist/src/apple-multitouch-support.js +1 -0
- package/dist/src/apps.js +5 -5
- package/dist/src/audio-probe.js +1 -1
- package/dist/src/boot-diagnostics.js +2 -0
- package/dist/src/cli-config.js +1 -0
- package/dist/src/cli-help.js +64 -30
- package/dist/src/cli-runner.js +1 -1
- package/dist/src/cli.js +15 -11
- package/dist/src/command-schema.js +3 -3
- package/dist/src/config.js +1 -0
- package/dist/src/context.js +1 -0
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/daemon-shutdown-report.js +1 -0
- package/dist/src/debug-symbols.js +1 -1
- package/dist/src/device-input-state.js +1 -1
- package/dist/src/devices2.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/generic.js +1 -1
- package/dist/src/helper.js +1 -1
- package/dist/src/index.d.ts +412 -289
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +4 -3
- package/dist/src/input-actions2.js +1 -1
- package/dist/src/install-artifact.js +1 -0
- package/dist/src/install-source.d.ts +5 -1
- package/dist/src/install-source.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/interaction-snapshot.js +1 -1
- package/dist/src/interaction.d.ts +230 -0
- package/dist/src/interaction.js +1 -1
- package/dist/src/interactor.js +2 -2
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +43 -17
- package/dist/src/internal/png-worker.d.ts +22 -0
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/launch-console.js +1 -0
- package/dist/src/lease-context.js +1 -0
- package/dist/src/lease.js +1 -1
- package/dist/src/linux.js +1 -1
- package/dist/src/logcat.js +5 -0
- package/dist/src/metro.d.ts +2 -2
- package/dist/src/notifications.js +1 -1
- package/dist/src/png-worker-contract.js +1 -1
- package/dist/src/process-lock.js +1 -0
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-trace.js +1 -1
- package/dist/src/register-builtins.js +1 -0
- package/dist/src/registry.js +24 -24
- package/dist/src/reporting.js +8 -7
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-disposal.js +2 -0
- package/dist/src/runner-lease.js +1 -0
- package/dist/src/runner-sequence.js +1 -1
- package/dist/src/runtime-transport.js +1 -1
- package/dist/src/runtime.js +3 -3
- package/dist/src/runtime2.js +1 -0
- package/dist/src/sdk-android-adb.d.ts +119 -33
- package/dist/src/sdk-android-adb.js +4 -4
- package/dist/src/sdk-app-inventory.js +1 -1
- package/dist/src/sdk-batch-runner.d.ts +2 -1
- package/dist/src/sdk-batch-runner.js +2 -2
- package/dist/src/sdk-batch.js +2 -2
- package/dist/src/sdk-contracts.d.ts +105 -98
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -0
- package/dist/src/sdk-finders.d.ts +3 -3
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-io.d.ts +1 -1
- package/dist/src/sdk-io.js +1 -1
- package/dist/src/sdk-remote-config.d.ts +9 -1
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selector-vocabulary.js +1 -0
- package/dist/src/selectors.d.ts +12 -3
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +3 -3
- package/dist/src/session-target-evidence.js +1 -0
- package/dist/src/session.js +8 -10
- package/dist/src/setting-state.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-diagnostics.js +5 -2
- package/dist/src/snapshot.js +1 -1
- package/dist/src/snapshot2.js +1 -2
- package/dist/src/tool-provider.js +2 -2
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/tv-remote.js +13 -12
- package/dist/src/url.js +1 -1
- package/dist/src/web.js +1 -1
- package/package.json +33 -20
- package/server.json +2 -2
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.19.2.apk +0 -0
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.19.2.apk.sha256 +0 -1
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.19.2.manifest.json +0 -10
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.19.2.apk +0 -0
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.19.2.apk.sha256 +0 -1
- package/dist/src/apple-runner-options.js +0 -1
- package/dist/src/cli-output.js +0 -1
- package/dist/src/client.js +0 -3
- package/dist/src/handler-utils.js +0 -1
- package/dist/src/output-path.js +0 -1
- package/dist/src/points.js +0 -4
- package/dist/src/provider.js +0 -1
- package/dist/src/providers.js +0 -1
- package/dist/src/record-trace-recording.js +0 -23
- package/dist/src/recording-provider.js +0 -1
- package/dist/src/selectors2.js +0 -1
- package/dist/src/simctl.js +0 -1
- package/dist/src/snapshot-helper.js +0 -5
- package/dist/src/ttl-memo.js +0 -1
- package/dist/src/xml.js +0 -2
- /package/{macos-helper → apple/macos-helper}/Package.swift +0 -0
- /package/{macos-helper → apple/macos-helper}/Sources/AgentDeviceMacOSHelper/AudioProbe.swift +0 -0
- /package/{macos-helper → apple/macos-helper}/Sources/AgentDeviceMacOSHelper/SnapshotTraversal.swift +0 -0
- /package/{macos-helper → apple/macos-helper}/Sources/AgentDeviceMacOSHelper/main.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/xcshareddata/xcschemes/AgentDeviceRunner.xcscheme +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests.entitlements +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerObjCExceptionCatcher.h +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerObjCExceptionCatcher.m +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTapPointPolicy.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Environment.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Exceptions.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/AgentDeviceRunnerUITests.xctestplan +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/RecordingScripts/recording-resize.swift +0 -0
- /package/dist/{apple-runner → apple/runner}/AgentDeviceRunner/RecordingScripts/recording-trim.swift +0 -0
- /package/{src/platforms/linux → linux}/atspi-dump.py +0 -0
|
@@ -5,6 +5,26 @@ type ScreenshotDiffPixelsResult = {
|
|
|
5
5
|
differentPixels: number;
|
|
6
6
|
};
|
|
7
7
|
//#endregion
|
|
8
|
+
//#region src/utils/png-rgb-difference.d.ts
|
|
9
|
+
type PngRgbComparisonMetadata = {
|
|
10
|
+
readonly first: {
|
|
11
|
+
readonly width: number;
|
|
12
|
+
readonly height: number;
|
|
13
|
+
readonly dataLength: number;
|
|
14
|
+
};
|
|
15
|
+
readonly second: {
|
|
16
|
+
readonly width: number;
|
|
17
|
+
readonly height: number;
|
|
18
|
+
readonly dataLength: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type PngRgbDifferenceResult = PngRgbComparisonMetadata & ({
|
|
22
|
+
readonly status: 'compared';
|
|
23
|
+
readonly differencePercent: number;
|
|
24
|
+
} | {
|
|
25
|
+
readonly status: 'dimension_mismatch' | 'data_length_mismatch';
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
8
28
|
//#region src/utils/png-worker-contract.d.ts
|
|
9
29
|
type PngWorkerJobResult = {
|
|
10
30
|
kind: 'decode';
|
|
@@ -15,6 +35,8 @@ type PngWorkerJobResult = {
|
|
|
15
35
|
kind: 'encode';
|
|
16
36
|
png: Uint8Array;
|
|
17
37
|
} | ({
|
|
38
|
+
kind: 'rgb-difference';
|
|
39
|
+
} & PngRgbDifferenceResult) | ({
|
|
18
40
|
kind: 'diff-pixels';
|
|
19
41
|
} & ScreenshotDiffPixelsResult);
|
|
20
42
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{S as e}from"../sdk-contracts.js";import{a as t,i as n,n as r,r as i,t as a}from"../png-worker-contract.js";import{parentPort as o}from"node:worker_threads";function s(e){switch(e.kind){case`decode`:{let t=n(a(e.png),e.label);return{kind:`decode`,width:t.width,height:t.height,data:t.data}}case`encode`:{let n=new t({width:e.width,height:e.height,data:a(e.data)});return{kind:`encode`,png:t.sync.write(n)}}case`rgb-difference`:return{kind:`rgb-difference`,...r(n(a(e.firstPng),e.label),n(a(e.secondPng),e.label))};case`diff-pixels`:return{kind:`diff-pixels`,...i(e)}}}function c(e){return e.buffer instanceof ArrayBuffer&&e.byteOffset===0&&e.byteLength===e.buffer.byteLength}function l(e){return u(e).filter(c).map(e=>e.buffer)}function u(e){switch(e.kind){case`decode`:return[e.data];case`encode`:return[e.png];case`rgb-difference`:return[];case`diff-pixels`:return[e.diffData,e.diffMask]}}const d=o;d&&d.on(`message`,t=>{let n;try{n={id:t.id,ok:!0,result:s(t)}}catch(r){n={id:t.id,ok:!1,error:e(r)}}d.postMessage(n,n.ok?l(n.result):[])});export{l as resultTransferList};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`--launch-console is supported only for iOS simulator app launches`,t=`--launch-console requires a direct app launch and cannot be used with URL opens`;export{e as n,t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Sn as e}from"./tv-remote.js";import{x as t}from"./sdk-batch-runner.js";function n(t){return e(t)}function r(e,r){let i=n(e),a=i.leaseId??r?.leaseId,o=i.tenantId??r?.tenantId,s=i.runId??r?.runId;if(!(!o||!s||!a))return t({tenantId:o,runId:s,leaseId:a,leaseBackend:i.leaseBackend??r?.backend,leaseProvider:i.leaseProvider??r?.leaseProvider,deviceKey:i.deviceKey??r?.deviceKey,clientId:i.clientId??r?.clientId,expiresAt:r?.expiresAt})}function i(e,r){let i=n(e),a=r?.lease??r?.deviceLease??void 0;return t({tenantId:i.tenantId??a?.tenantId,runId:i.runId??a?.runId,leaseId:i.leaseId??a?.leaseId,leaseTtlMs:i.leaseTtlMs,leaseBackend:i.leaseBackend??a?.leaseBackend,leaseProvider:i.leaseProvider??a?.leaseProvider,deviceKey:i.deviceKey??a?.deviceKey,clientId:i.clientId??a?.clientId})}function a(e){let n=e.meta,r=t({leaseId:o(n?.leaseId),clientId:o(n?.clientId),tenantId:o(n?.tenantId),runId:o(n?.runId),leaseProvider:o(n?.leaseProvider),deviceKey:o(n?.deviceKey)});return Object.keys(r).length>0?r:void 0}function o(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}export{a as i,n,i as r,r as t};
|
package/dist/src/lease.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{Cn as t,En as n,On as r,bn as i,rr as a}from"./tv-remote.js";import{n as o,r as s}from"./lease-context.js";import{On as c}from"./internal/daemon.js";async function l(e){let{req:i,sessionName:c,sessionStore:l,leaseRegistry:f,providerRuntimeIds:p,providerRuntimeRequiredIds:m,leaseLifecycleProvider:h,cloudArtifactProvider:g}=e,_=o(i);switch(i.command){case a.artifacts:return{ok:!0,data:await d(i,s(i,l.get(c)),g)};case`lease_allocate`:{u(_.leaseProvider,p,m);let e=f.allocateLease(t(_)),n;try{n=await h?.allocate?.(e,{req:i})}catch(t){throw f.releaseLease(r({leaseId:e.leaseId,tenantId:e.tenantId,runId:e.runId,leaseBackend:e.backend,leaseProvider:e.leaseProvider,deviceKey:e.deviceKey,clientId:e.clientId})),t}return{ok:!0,data:{lease:e,...n?{provider:n}:{}}}}case`lease_heartbeat`:{let e=f.heartbeatLease(n(_)),t=await h?.heartbeat?.(e,{req:i});return{ok:!0,data:{lease:e,...t?{provider:t}:{}}}}case`lease_release`:{let e=r(_),t=f.getLease(e),n=t?await h?.release?.(t,{req:i}):void 0;return{ok:!0,data:{released:f.releaseLease(e).released,...n?{provider:n}:{}}}}default:return null}}function u(t,n,r){if(!(!t||n===void 0||r===void 0||!r.includes(t)||n.includes(t)))throw new e(`UNSUPPORTED_OPERATION`,`Provider "${t}" is not available in this daemon runtime.`,{provider:t,hint:`Restart the daemon with ${t} configured, then retry lease allocation.`})}async function d(e,t,n){let r=h(e.flags,`providerSessionId`);return f(t,r)?await p(t.tenantId):await m(t,r,n)}function f(e,t){return i(e)||!e.leaseProvider&&!t}async function p(e){let t=await c(e);return{source:`daemon`,status:`ready`,artifacts:t,...t.length===0?{message:`No daemon artifacts available.`}:{}}}async function m(t,n,r){if(!t.leaseProvider)throw new e(`INVALID_ARGS`,`artifacts requires --provider for provider session lookup or an active cloud connection.`);if(!t.leaseId&&!n)throw new e(`INVALID_ARGS`,`artifacts requires an active cloud lease or --provider-session <id>.`);let i=await r?.listCloudArtifacts?.({provider:t.leaseProvider,leaseId:t.leaseId,providerSessionId:n});if(!i)throw new e(`UNSUPPORTED_OPERATION`,`Cloud artifacts are not available for provider "${t.leaseProvider}".`);return i}function h(e,t){let n=e?.[t];return typeof n==`string`&&n.length>0?n:void 0}export{l as handleLeaseCommands};
|
package/dist/src/linux.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{F as t}from"./sdk-android-adb.js";import{a as n}from"./runtime.js";import{t as r}from"./snapshot.js";import{t as i}from"./tool-provider2.js";import{doubleClickLinux as a,fillLinux as o,focusLinux as s,longPressLinux as c,pressLinux as l,scrollLinux as u,sendKey as d,swipeLinux as f,typeLinux as p}from"./input-actions2.js";async function m(e){await i().desktop.openTarget(e)}async function h(e){await i().desktop.closeApp(e)}async function g(){await d(`alt+Left`,[`56:1`,`105:1`,`105:0`,`56:0`])}async function _(){await d(`super+d`,[`125:1`,`32:1`,`32:0`,`125:0`])}async function v(){return await i().clipboard.readText()}async function y(e){await i().clipboard.writeText(e)}async function b(e,t){await i().screenshot.capture(e,t)}function x(){return{open:e=>m(e),openDevice:()=>Promise.resolve(),close:e=>h(e),tap:(e,t)=>l(e,t),doubleTap:(e,t)=>a(e,t),longPress:(e,t,n)=>c(e,t,n),focus:(e,t)=>s(e,t),type:(e,t)=>p(e,t),fill:(e,t,n,r)=>o(e,t,n,r),scroll:(e,t)=>u(e,t),performGesture:async t=>{if(t.topology===`two`)throw new e(`UNSUPPORTED_OPERATION`,`Multi-touch gestures are not supported on Linux`);let{start:r,end:i}=n(t);await f(r.x,r.y,i.x,i.y,t.durationMs)},screenshot:(e,t)=>b(e,t),snapshot:async e=>{let n=await t(`snapshot_capture`,async()=>await r(e?.surface),{backend:`linux-atspi`});return{nodes:n.nodes??[],truncated:n.truncated??!1,backend:`linux-atspi`}},back:()=>g(),home:()=>_(),setOrientation:()=>{throw new e(`UNSUPPORTED_OPERATION`,`orientation not supported on Linux`)},appSwitcher:()=>{throw new e(`UNSUPPORTED_OPERATION`,`appSwitcher not yet supported on Linux`)},tvRemote:()=>{throw new e(`UNSUPPORTED_OPERATION`,`tv-remote not supported on Linux`)},readClipboard:()=>v(),writeClipboard:e=>y(e),setSetting:()=>{throw new e(`UNSUPPORTED_OPERATION`,`setSetting not supported on Linux`)}}}export{x as createLinuxInteractor};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime.js";import{_ as t,v as n}from"./sdk-contracts.js";import{b as r,h as i,n as a,r as o,s,v as c,w as l}from"./sdk-android-adb.js";import{t as u}from"./timeouts.js";import{n as d,t as f}from"./manifest.js";import{n as p,r as m}from"./install-source2.js";import{a as h,l as g,n as _,s as ee,t as v}from"./boot-diagnostics.js";import"node:fs";import y from"node:path";function b(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=/^([A-Za-z][A-Za-z0-9+.-]*):(.+)$/.exec(t);if(!n)return!1;let r=n[1]?.toLowerCase(),i=n[2]??``;return r===`http`||r===`https`||r===`ws`||r===`wss`||r===`ftp`||r===`ftps`?i.startsWith(`//`):!0}function x(e){let t=e.trim().split(`:`)[0]?.toLowerCase();return t===`http`||t===`https`}function te(e,t){let n=e?.trim();if(n)return n;if(x(t))return`com.apple.mobilesafari`}function S(e={}){let t=e.ttlMs??3e4,n=e.nowMs??Date.now,r=new Map,i=e=>{let t=w(e);for(let e of r.keys())e.startsWith(t)&&r.delete(e)};return{get(e,t){let i=C(e,t),a=r.get(i);if(a){if(a.expiresAtMs<=n()){r.delete(i);return}return a.value}},set(e,i,a){return r.set(C(e,i),{value:a,expiresAtMs:n()+t}),a},clear(e){i(e)},async invalidateWhile(e,t){i(e);try{return await t()}finally{i(e)}}}}function C(e,t){return[e.platform,e.deviceId,e.variant??``,t.trim().toLowerCase()].join(`\0`)}function w(e){return[e.platform,e.deviceId,``].join(`\0`)}var T=e({ensureAndroidEmulatorBooted:()=>oe,listAndroidDevices:()=>W,parseAndroidAvdList:()=>q,parseAndroidEmulatorAvdNameOutput:()=>N,parseAndroidFeatureListForTv:()=>B,parseAndroidTargetFromCharacteristics:()=>z,resolveAndroidAvdName:()=>J,resolveAndroidEmulatorAvdName:()=>R,waitForAndroidBoot:()=>Q});const E=1e4,D=[`android.software.leanback`,`android.software.leanback_only`,`android.hardware.type.television`];async function O(e,t,n){let r=Array(e.length),i=0,a=Math.min(t,e.length);return await Promise.all(Array.from({length:a},async()=>{for(;i<e.length;){let t=i;i+=1,r[t]=await n(e[t])}})),r}function k(e){return`${e.stdout}\n${e.stderr}`}function A(e,t){return[`-s`,e,...t]}function j(e){return e.startsWith(`emulator-`)}function M(e){return e.toLowerCase().replace(/_/g,` `).replace(/\s+/g,` `).trim()}function N(e){let t=e.split(`
|
|
2
|
+
`).map(e=>e.trim()).filter(e=>e.length>0);if(t.length!==0)return t.at(-1)===`OK`&&t.pop(),t.join(`
|
|
3
|
+
`).trim()||void 0}async function P(e,t=E){return c(`adb`,A(e,[`shell`,`getprop`,`sys.boot_completed`]),{allowFailure:!0,timeoutMs:t})}async function F(e,t){let n=t.replace(/_/g,` `).trim();if(!j(e))return n||e;let r=await R(e);return r?r.replace(/_/g,` `):n||e}async function I(e,t,r){try{return await r(`adb`,A(e,t),{allowFailure:!0,timeoutMs:1e4})}catch(e){if(L(n(e)))return;throw e}}function L(e){return e.code===`COMMAND_FAILED`&&typeof e.details?.timeoutMs==`number`}async function R(e,t=c){for(let n of[`ro.boot.qemu.avd_name`,`persist.sys.avd_name`]){let r=await I(e,[`shell`,`getprop`,n],t);if(!r)continue;let i=r.stdout.trim();if(r.exitCode===0&&i.length>0)return i}let n=await I(e,[`emu`,`avd`,`name`],t);if(!n)return;let r=N(n.stdout);if(n.exitCode===0&&r)return r}function z(e){let t=e.toLowerCase();return t.includes(`tv`)||t.includes(`leanback`)?`tv`:null}function B(e){return/feature:android\.(software\.leanback(_only)?|hardware\.type\.television)\b/i.test(e)}async function V(e,t){let n=k(await c(`adb`,A(e,[`shell`,`cmd`,`package`,`has-feature`,t]),{allowFailure:!0,timeoutMs:E})).toLowerCase();return n.includes(`true`)?!0:n.includes(`false`)?!1:null}async function H(e){return(await O(D,2,async t=>await V(e,t))).some(e=>e===!0)}async function U(e){return z(k(await c(`adb`,A(e,[`shell`,`getprop`,`ro.build.characteristics`]),{allowFailure:!0,timeoutMs:E})))===`tv`||await H(e)||B(k(await c(`adb`,A(e,[`shell`,`pm`,`list`,`features`]),{allowFailure:!0,timeoutMs:E})))?`tv`:`mobile`}async function W(e={}){if(await d(),!await l(`adb`))throw new t(`TOOL_MISSING`,`adb not found in PATH`);let n=e.serialAllowlist??h(void 0),r=await O((await K()).filter(e=>!n||n.has(e.serial)),3,async({serial:e,rawModel:t})=>{let[n,r,i]=await Promise.all([F(e,t),ae(e),U(e)]);return{platform:`android`,id:e,name:n,kind:j(e)?`emulator`:`device`,target:i,booted:r}});return[...r,...await X(r)]}function G(e){return e.split(`
|
|
4
|
+
`).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`List of devices`)).map(e=>e.split(/\s+/)).flatMap(e=>{let t=e[0];return t===void 0||e[1]!==`device`?[]:[{serial:t,rawModel:(e.find(e=>e.startsWith(`model:`))??``).replace(`model:`,``)}]})}async function K(){try{return G((await c(`adb`,[`devices`,`-l`],{timeoutMs:E})).stdout)}catch(e){throw o(e)}}function q(e){return e.split(`
|
|
5
|
+
`).map(e=>e.trim()).filter(e=>e.length>0)}function J(e,t){let n=e.find(e=>e===t);if(n)return n;let r=M(t);return e.find(e=>M(e)===r)}async function Y(){return q(i(await c(`emulator`,[`-list-avds`],{allowFailure:!0,timeoutMs:E}),`Failed to list Android emulator AVDs`,{hint:`Verify Android emulator tooling is installed and available in PATH.`}).stdout)}async function X(e){let t=await Y().catch(()=>[]),n=new Set(e.filter(e=>e.kind===`emulator`).map(e=>M(e.name)));return t.filter(e=>!n.has(M(e))).map(e=>({platform:`android`,id:e,name:e,kind:`emulator`,target:Z(e),booted:!1}))}function Z(e){return/\b(tv|television)\b/i.test(M(e))?`tv`:`mobile`}function ne(e,t,n){let r=M(t);return e.find(e=>e.platform!==`android`||e.kind!==`emulator`||n&&e.id!==n?!1:M(e.name)===r)}async function re(e){let n=Date.now(),r=Math.min(1e3,Math.max(50,Math.floor(e.timeoutMs/20)));for(;Date.now()-n<e.timeoutMs;){try{let t=await ie(e.avdName,e.serial);if(t)return{platform:`android`,id:t,name:e.avdName,kind:`emulator`,target:`mobile`,booted:!1}}catch{}await u(r)}throw new t(`COMMAND_FAILED`,`Android emulator did not appear in time`,{avdName:e.avdName,serial:e.serial,timeoutMs:e.timeoutMs,hint:`Check emulator logs and verify the AVD can start from command line.`})}async function ie(e,t){let n=M(e),r=(await K()).filter(e=>t&&e.serial!==t?!1:j(e.serial));for(let e of r)if(M(e.rawModel)===n||M(await F(e.serial,e.rawModel))===n)return e.serial}async function ae(e){try{return(await P(e)).stdout.trim()===`1`}catch{return!1}}async function oe(e){await d();let n=e.avdName.trim();if(!n)throw new t(`INVALID_ARGS`,`Android emulator boot requires a non-empty AVD name.`);let i=e.timeoutMs??12e4;if(!await l(`adb`))throw new t(`TOOL_MISSING`,`adb not found in PATH`);if(!await l(`emulator`))throw new t(`TOOL_MISSING`,`emulator not found in PATH`);let a=await Y(),o=J(a,n);if(!o)throw new t(`DEVICE_NOT_FOUND`,`No Android emulator AVD named ${e.avdName}`,{requestedAvdName:n,availableAvds:a,hint:"Run `emulator -list-avds` and pass an existing AVD name to --device."});let s=Date.now(),c=ne(await W(),o,e.serial),u=c&&j(c.id)?c:void 0;if(!u){let t=[`-avd`,o];e.headless&&t.push(`-no-window`,`-no-audio`),r(`emulator`,t)}let f=u??await re({avdName:o,serial:e.serial,timeoutMs:i}),p=Date.now()-s,m=Math.max(1e3,i-p);await Q(f.id,m);let h=(await W()).find(e=>e.id===f.id);return h?{...h,name:o,booted:!0}:{...f,name:o,booted:!0}}async function Q(e,r=6e4){let i=r,a=ee.fromTimeoutMs(i),o=Math.min(1e3,Math.max(50,Math.floor(i/20))),s=Math.max(1,Math.ceil(i/o)),c,l=!1;try{await g(async({deadline:n})=>{if(n?.isExpired())throw l=!0,new t(`COMMAND_FAILED`,`Android boot deadline exceeded`,{serial:e,timeoutMs:r,elapsedMs:a.elapsedMs(),message:`timeout`});let o=Math.max(1e3,n?.remainingMs()??i),s=await P(e,Math.min(o,E));if(c=s,s.stdout.trim()!==`1`)throw new t(`COMMAND_FAILED`,`Android device is still booting`,{serial:e,stdout:s.stdout,stderr:s.stderr,exitCode:s.exitCode})},{maxAttempts:s,baseDelayMs:o,maxDelayMs:o,jitter:0,shouldRetry:e=>{let t=_({error:e,stdout:c?.stdout,stderr:c?.stderr,context:{platform:`android`,phase:`boot`}});return t!==`ADB_TRANSPORT_UNAVAILABLE`&&t!==`ANDROID_BOOT_TIMEOUT`}},{deadline:a,phase:`boot`,classifyReason:e=>_({error:e,stdout:c?.stdout,stderr:c?.stderr,context:{platform:`android`,phase:`boot`}})})}catch(r){let o=n(r),s=c?.stdout,u=c?.stderr,d=c?.exitCode,f=_({error:r,stdout:s,stderr:u,context:{platform:`android`,phase:`boot`}});f===`BOOT_COMMAND_FAILED`&&o.message===`Android device is still booting`&&(f=`ANDROID_BOOT_TIMEOUT`);let p={serial:e,timeoutMs:i,elapsedMs:a.elapsedMs(),reason:f,hint:v(f),stdout:s,stderr:u,exitCode:d};throw l||f===`ANDROID_BOOT_TIMEOUT`?new t(`COMMAND_FAILED`,`Android device did not finish booting in time`,p):o.code===`TOOL_MISSING`?new t(`TOOL_MISSING`,o.message,{...p,...o.details??{}}):f===`ADB_TRANSPORT_UNAVAILABLE`?new t(`COMMAND_FAILED`,o.message,{...p,...o.details??{}}):new t(o.code,o.message,{...p,...o.details??{}},o.cause)}}async function se(e,t,n){return await s(e)(t,n)}function ce(e){return{platform:`android`,id:e,name:e,kind:e.startsWith(`emulator-`)?`emulator`:`device`,booted:!0}}function le(e,t){let n=`${e}\n${t}`.toLowerCase();return n.includes(`no shell command implementation`)||n.includes(`unknown command`)}var ue=e({prepareAndroidInstallArtifact:()=>$});async function $(e,t){let n=e.kind===`url`&&p(e.url),r=await m({source:e,isInstallablePath:(e,t)=>t.isFile()&&de(e),installableLabel:`Android installable (.apk or .aab)`,allowArchiveExtraction:e.kind!==`url`||n,signal:t?.signal});try{let e=t?.resolveIdentity===!1?{}:await fe(r.installablePath);return{archivePath:r.archivePath,installablePath:r.installablePath,packageName:e.packageName,cleanup:r.cleanup}}catch(e){throw await r.cleanup(),e}}function de(e){let t=y.extname(e).toLowerCase();return t===`.apk`||t===`.aab`}async function fe(e){let t=y.extname(e).toLowerCase();return t!==`.apk`&&t!==`.aab`?{}:{packageName:await f(e)}}async function pe(e,t={}){let n=[`logcat`,`-d`,`-v`,`time`];t.lines!==void 0&&n.push(`-t`,String(Math.max(1,Math.floor(t.lines))));let r=await e(n,{allowFailure:!0,timeoutMs:t.timeoutMs,signal:t.signal});if(r.exitCode!==0)throw a(`Failed to capture Android logcat`,r);return r.stdout}function me(e,n={}){if(!e.spawn)throw new t(`UNSUPPORTED_OPERATION`,`Android ADB provider does not support streams`,{capability:`adb.spawn`});let r=[`logcat`,`-v`,`time`];n.pid&&r.push(`--pid`,n.pid);let i=e.spawn(r,{stdio:[`ignore`,`pipe`,`pipe`],signal:n.signal});return n.output&&i.stdout&&i.stdout.pipe(n.output,{end:!1}),i}export{ce as a,T as c,b as d,x as f,$ as i,Q as l,me as n,le as o,te as p,ue as r,se as s,pe as t,S as u};
|
package/dist/src/metro.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { x as SessionRuntimeHints } from "./sdk-contracts.js";
|
|
2
2
|
import { s as MetroBridgeDescriptor } from "./sdk-remote-config.js";
|
|
3
3
|
//#region src/utils/url.d.ts
|
|
4
4
|
declare function normalizeBaseUrl(input: string): string;
|
|
5
|
-
declare function buildBundleUrl(baseUrl: string, platform: 'ios' | 'android'): string;
|
|
5
|
+
declare function buildBundleUrl(baseUrl: string, platform: 'ios' | 'android', entryPath?: string): string;
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/metro/metro.d.ts
|
|
8
8
|
declare function resolveRuntimeTransport(runtime: SessionRuntimeHints | undefined): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{s as t}from"./logcat.js";async function n(n,i,a){let o=typeof a.action==`string`&&a.action.trim()?a.action.trim():`${i}.TEST_PUSH`,s=[`shell`,`am`,`broadcast`,`-a`,o,`-p`,i],c=typeof a.receiver==`string`?a.receiver.trim():``;c&&s.push(`-n`,c);let l=a.extras;if(l!==void 0&&(typeof l!=`object`||!l||Array.isArray(l)))throw new e(`INVALID_ARGS`,`Android push payload extras must be an object`);let u=l??{},d=0;for(let[e,t]of Object.entries(u))e&&(r(s,e,t),d+=1);return await t(n,s),{action:o,extrasCount:d}}function r(t,n,r){if(typeof r==`string`){t.push(`--es`,n,r);return}if(typeof r==`boolean`){t.push(`--ez`,n,r?`true`:`false`);return}if(typeof r==`number`&&Number.isFinite(r)){if(Number.isInteger(r)){t.push(`--ei`,n,String(r));return}t.push(`--ef`,n,String(r));return}throw new e(`INVALID_ARGS`,`Unsupported Android broadcast extra type for "${n}". Use string, boolean, or number.`)}export{n as pushAndroidNotification};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{deflateSync as t,inflateSync as n}from"node:zlib";const r=Buffer.from([137,80,78,71,13,10,26,10]),i=new Map([[0,1],[2,3],[3,1],[4,2],[6,4]]),a=new Map([[0,new Set([1,2,4,8,16])],[2,new Set([8,16])],[3,new Set([1,2,4,8])],[4,new Set([8,16])],[6,new Set([8,16])]]),o=[{x:0,y:0,dx:8,dy:8},{x:4,y:0,dx:8,dy:8},{x:0,y:4,dx:4,dy:8},{x:2,y:0,dx:4,dy:4},{x:0,y:2,dx:2,dy:4},{x:1,y:0,dx:2,dy:2},{x:0,y:1,dx:1,dy:2}];var s=class{width;height;data;static sync={read:c,write:p};constructor(e){this.width=I(e.width,`width`),this.height=I(e.height,`height`);let t=this.width*this.height*4;if(this.data=e.data?Buffer.from(e.data):Buffer.alloc(t),this.data.length!==t)throw Error(`PNG data length must be ${t} bytes`)}};function c(e){let{metadata:t,idatChunks:n}=l(e);if(!t)throw Error(`PNG is missing IHDR`);if(n.length===0)throw Error(`PNG is missing IDAT`);let r=f(n,t);return new s({width:t.width,height:t.height,data:t.interlace===1?b(r,t):y(g(r,t),t)})}function l(e){let t,n=[];for(let r of d(e))if(r.type===`IHDR`?t=m(r.data):r.type===`IDAT`?n.push(Buffer.from(r.data)):t=u(r,t),r.type===`IEND`)break;return{metadata:t,idatChunks:n}}function u(e,t){if(e.type===`PLTE`){if(!t)throw Error(`PNG PLTE appeared before IHDR`);t.palette=Buffer.from(e.data)}else if(e.type===`tRNS`){if(!t)throw Error(`PNG tRNS appeared before IHDR`);t.transparency=Buffer.from(e.data)}return t}function*d(e){if(!e.subarray(0,r.length).equals(r))throw Error(`Invalid PNG signature`);let t=r.length;for(;t<e.length;){if(t+12>e.length)throw Error(`Truncated PNG chunk`);let n=e.readUInt32BE(t),r=e.toString(`ascii`,t+4,t+8),i=t+8,a=i+n;if(a+4>e.length)throw Error(`Truncated PNG ${r} chunk`);let o=e.subarray(i,a),s=e.readUInt32BE(a);if(P(e.subarray(t+4,a))!==s)throw Error(`Invalid PNG ${r} chunk CRC`);t=a+4,yield{type:r,data:o}}}function f(e,t){let r=x(t);try{let t=n(Buffer.concat(e),{maxOutputLength:r});if(t.length!==r)throw Error(`PNG pixel data is truncated`);return t}catch(e){throw L(e)?Error(`PNG pixel data exceeds expected length ${r}`):e}}function p(e){let n=e.width*4,i=Buffer.alloc((n+1)*e.height);for(let t=0;t<e.height;t+=1){let r=t*(n+1);i[r]=0,e.data.copy(i,r+1,t*n,(t+1)*n)}let a=Buffer.alloc(13);return a.writeUInt32BE(e.width,0),a.writeUInt32BE(e.height,4),a[8]=8,a[9]=6,a[10]=0,a[11]=0,a[12]=0,Buffer.concat([r,N(`IHDR`,a),N(`IDAT`,t(i)),N(`IEND`,Buffer.alloc(0))])}function m(e){if(e.length!==13)throw Error(`Invalid PNG IHDR length`);let t=e.readUInt32BE(0),n=e.readUInt32BE(4),r=e[8],i=e[9],o=e[10],s=e[11],c=e[12];if(!h(i))throw Error(`Unsupported PNG color type ${i}`);if(!a.get(i)?.has(r))throw Error(`Unsupported PNG color type ${i} with bit depth ${r}`);if(o!==0)throw Error(`Unsupported PNG compression method ${o}`);if(s!==0)throw Error(`Unsupported PNG filter method ${s}`);if(c!==0&&c!==1)throw Error(`Unsupported PNG interlace method ${c}`);return{width:I(t,`width`),height:I(n,`height`),bitDepth:r,colorType:i,interlace:c}}function h(e){return i.has(e)}function g(e,t){return _({inflated:e,offset:0,scanlineLength:O(t),height:t.height,bytesPerPixel:k(t)}).raw}function _(e){let{inflated:t,offset:n,scanlineLength:r,height:i,bytesPerPixel:a}=e,o=n+(r+1)*i;if(t.length<o)throw Error(`PNG pixel data is truncated`);let s=Buffer.alloc(r*i);for(let e=0;e<i;e+=1){let i=n+e*(r+1),o=e*r,c=t[i];for(let n=0;n<r;n+=1){let l=t[i+1+n],u=n>=a?s[o+n-a]:0,d=e>0?s[o+n-r]:0,f=e>0&&n>=a?s[o+n-r-a]:0;s[o+n]=v(c,l,u,d,f)}}return{raw:s,offset:o}}function v(e,t,n,r,i){if(e===0)return t;if(e===1)return t+n&255;if(e===2)return t+r&255;if(e===3)return t+Math.floor((n+r)/2)&255;if(e===4)return t+F(n,r,i)&255;throw Error(`Unsupported PNG filter type ${e}`)}function y(e,t){let n=Buffer.alloc(t.width*t.height*4),r=O(t);for(let i=0;i<t.height;i+=1){let a=e.subarray(i*r,(i+1)*r);for(let e=0;e<t.width;e+=1){let r=(i*t.width+e)*4,[o,s,c,l]=w(a,e,t);n[r]=o,n[r+1]=s,n[r+2]=c,n[r+3]=l}}return n}function b(e,t){let n=Buffer.alloc(t.width*t.height*4),r=0;for(let i of o){let a=C(t.width,i.x,i.dx),o=C(t.height,i.y,i.dy);if(a===0||o===0)continue;let s={...t,width:a,height:o,interlace:0},c=_({inflated:e,offset:r,scanlineLength:O(s),height:o,bytesPerPixel:k(s)});r=c.offset;let l=O(s);for(let e=0;e<o;e+=1){let r=c.raw.subarray(e*l,(e+1)*l);for(let o=0;o<a;o+=1){let a=i.x+o*i.dx,c=((i.y+e*i.dy)*t.width+a)*4,[l,u,d,f]=w(r,o,s);n[c]=l,n[c+1]=u,n[c+2]=d,n[c+3]=f}}}return n}function x(e){if(e.interlace===0)return S(e,e.height);let t=0;for(let n of o){let r=C(e.width,n.x,n.dx),i=C(e.height,n.y,n.dy);r===0||i===0||(t+=S({...e,width:r,height:i},i))}return t}function S(e,t){return(O(e)+1)*t}function C(e,t,n){return e<=t?0:Math.floor((e-t+n-1)/n)}function w(e,t,n){if(n.colorType===3)return T(e,t,n);if(n.bitDepth<8)return E(e,t,n);let r=n.bitDepth===16?2:1,a=t*i.get(n.colorType)*r,o=t=>n.bitDepth===16?e.readUInt16BE(a+t*2):e[a+t*r],s=e=>A(o(e),n.bitDepth);if(n.colorType===0){let e=s(0);return[e,e,e,j(o(0),n)?0:255]}if(n.colorType===2)return[s(0),s(1),s(2),M(o(0),o(1),o(2),n)?0:255];if(n.colorType===4){let e=s(0);return[e,e,e,s(1)]}return[s(0),s(1),s(2),s(3)]}function T(e,t,n){if(!n.palette)throw Error(`Indexed PNG is missing PLTE`);let r=D(e,t,n.bitDepth),i=r*3;if(i+2>=n.palette.length)throw Error(`Indexed PNG palette is invalid`);return[n.palette[i],n.palette[i+1],n.palette[i+2],n.transparency?.[r]??255]}function E(e,t,n){let r=D(e,t,n.bitDepth),i=(1<<n.bitDepth)-1,a=Math.round(r/i*255);return[a,a,a,n.transparency&&n.transparency.length>=2&&r===n.transparency.readUInt16BE(0)?0:255]}function D(e,t,n){let r=t*n;return e[Math.floor(r/8)]>>8-n-r%8&(1<<n)-1}function O(e){let t=i.get(e.colorType);return Math.ceil(e.width*t*e.bitDepth/8)}function k(e){let t=i.get(e.colorType);return Math.max(1,Math.ceil(t*e.bitDepth/8))}function A(e,t){return t===16?Math.round(e/65535*255):e}function j(e,t){return!t.transparency||t.transparency.length<2?!1:e===t.transparency.readUInt16BE(0)}function M(e,t,n,r){return!r.transparency||r.transparency.length<6?!1:e===r.transparency.readUInt16BE(0)&&t===r.transparency.readUInt16BE(2)&&n===r.transparency.readUInt16BE(4)}function N(e,t){let n=Buffer.from(e,`ascii`),r=Buffer.alloc(8+t.length+4);return r.writeUInt32BE(t.length,0),n.copy(r,4),t.copy(r,8),r.writeUInt32BE(P(Buffer.concat([n,t])),8+t.length),r}function P(e){let t=4294967295;for(let n of e){t^=n;for(let e=0;e<8;e+=1)t=t&1?3988292384^t>>>1:t>>>1}return(t^4294967295)>>>0}function F(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function I(e,t){if(!Number.isInteger(e)||e<1)throw Error(`PNG ${t} must be positive`);return e}function L(e){return e instanceof Error&&`code`in e&&e.code===`ERR_BUFFER_TOO_LARGE`}function R(t,n){try{return s.sync.read(t)}catch(t){throw new e(`COMMAND_FAILED`,`Failed to decode ${n} as PNG`,{label:n,reason:t instanceof Error?t.message:String(t)})}}const z=.78,B={r:220,g:0,b:0};function V(e){let{baselineData:t,currentData:n,maxColorDistance:r}=e,i=e.width*e.height,a=Buffer.alloc(i*4),o=new Uint8Array(i),s=0;for(let e=0,i=0;e<t.length;e+=4,i+=1){let c=t[e]-n[e],l=t[e+1]-n[e+1],u=t[e+2]-n[e+2];if(Math.sqrt(c**2+l**2+u**2)>r){s+=1,o[i]=1;let t=H(n,e);a[e]=U(t,B.r,z),a[e+1]=U(t,B.g,z),a[e+2]=U(t,B.b,z),a[e+3]=255;continue}let d=H(n,e);a[e]=d,a[e+1]=d,a[e+2]=d,a[e+3]=255}return{diffData:a,diffMask:o,differentPixels:s}}function H(e,t){return U(Math.round(e[t]*.299+e[t+1]*.587+e[t+2]*.114),255,.72)}function U(e,t,n){return Math.round(e*(1-n)+t*n)}function W(e,t){let n={first:{width:e.width,height:e.height,dataLength:e.data.length},second:{width:t.width,height:t.height,dataLength:t.data.length}};if(e.width!==t.width||e.height!==t.height)return{...n,status:`dimension_mismatch`};let r=e.width*e.height;if(e.data.length!==t.data.length||e.data.length!==r*4)return{...n,status:`data_length_mismatch`};let i=0;for(let n=0;n<e.data.length;n+=4)i+=Math.abs(e.data[n]-t.data[n]),i+=Math.abs(e.data[n+1]-t.data[n+1]),i+=Math.abs(e.data[n+2]-t.data[n+2]);return{...n,status:`compared`,differencePercent:100*i/(765*r)}}function G(e){return Buffer.from(e.buffer,e.byteOffset,e.byteLength)}export{s as a,R as i,W as n,V as r,G as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{t}from"./timeouts.js";import{n,o as r}from"./host-process.js";import i from"node:fs";import a from"node:path";async function o(n){let{lockDirPath:r,owner:o}=n,l=a.join(r,`owner.json`),d=Date.now()+(n.timeoutMs??3e4),f=n.pollMs??100,p=n.ownerGraceMs??5e3,m=n.description??`process lock`;for(i.mkdirSync(a.dirname(r),{recursive:!0});Date.now()<d;)try{i.mkdirSync(r),s(l,o);let e=!1;return async()=>{e||(e=!0,i.rmSync(r,{recursive:!0,force:!0}))}}catch(e){let n=e;if(n.code!==`EEXIST`)throw n;if(c(r,l,p))continue;await t(f)}throw new e(`COMMAND_FAILED`,`Timed out waiting for ${m}`,{lockDirPath:r,...u(r,l)})}function s(e,t){let n=`${e}.${process.pid}.${Date.now()}.tmp`;i.writeFileSync(n,JSON.stringify(t),`utf8`),i.renameSync(n,e)}function c(e,t,n){let r=null;try{r=i.statSync(e)}catch{return!0}let a=l(t);return a?d(a)?!1:(i.rmSync(e,{recursive:!0,force:!0}),!0):Date.now()-r.mtimeMs<n?!1:(i.rmSync(e,{recursive:!0,force:!0}),!0)}function l(e){try{return JSON.parse(i.readFileSync(e,`utf8`))}catch{return null}}function u(e,t){let n=Date.now(),r=l(t),a;try{a=Math.max(0,Math.round(n-i.statSync(e).mtimeMs))}catch{}return{...a===void 0?{}:{lockAgeMs:a},...r?{ownerPid:r.pid,ownerStartTime:r.startTime,ownerAgeMs:Math.max(0,Math.round(n-r.acquiredAtMs))}:{}}}function d(e){return!Number.isInteger(e.pid)||e.pid<=0||!n(e.pid)?!1:e.startTime?r(e.pid)===e.startTime:!0}export{o as t};
|
package/dist/src/react-native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{S as e}from"./sdk-contracts.js";import{qn as t,rr as n}from"./tv-remote.js";import{x as r}from"./sdk-batch-runner.js";import{t as i}from"./snapshot-quality.js";import{h as a}from"./runtime.js";import{c as o,l as s,n as c,s as l}from"./context.js";import{$t as u}from"./internal/daemon.js";import{i as d,n as f,t as p}from"./interaction-snapshot.js";async function m(t){let{req:r,sessionName:c,sessionStore:l}=t;if(r.command!==n.reactNative)return null;let u=h(r.positionals??[]);if(!u.ok)return u.response;let d=l.get(c);if(!d)return o();let f=s(n.reactNative,d.device,{message:`react-native dismiss-overlay is not supported on this device`});if(f)return f;try{let e=await p(d,r.flags,l,t.contextFromFlags,{interactiveOnly:!0});if(i(e.snapshotQuality))return _(e.snapshotQuality);let n=a(e.nodes),o=n.primaryAction;return o?await v(t,d,e,o):g(n.detected)}catch(t){return{ok:!1,error:e(t)}}}function h(e){return e.length===1&&e[0]===`dismiss-overlay`?{ok:!0}:{ok:!1,response:l(`INVALID_ARGS`,`react-native supports only: dismiss-overlay`)}}function g(e){return e?l(`COMMAND_FAILED`,`React Native overlay detected, but no safe dismiss target was found`,{hint:`Use screenshot --overlay-refs for visual evidence and report the overlay instead of pressing the warning body.`}):{ok:!0,data:{action:`dismiss-overlay`,detected:!1,dismissed:!1,...t(`No React Native overlay detected`)}}}function _(e){return l(`COMMAND_FAILED`,`React Native overlay state could not be determined because the accessibility tree is unreadable`,{reason:e.reason,hint:`The snapshot quality verdict is sparse. Use screenshot as visual truth; if an overlay is visible, report it or navigate with coordinates, then retry snapshot or dismiss-overlay on a readable screen.`})}async function v(e,n,i,a){let{req:o,sessionStore:s}=e,l=Date.now();u(n);let p=await c(n.device,`press`,[String(a.point.x),String(a.point.y)],o.flags?.out,e.contextFromFlags(o.flags,n.appBundleId,n.trace?.outPath))??{},m=Date.now(),h=await y(e,n),g=r({...f(i.nodes),...p,action:`dismiss-overlay`,overlayAction:a.action,x:a.point.x,y:a.point.y,ref:a.ref,label:a.label,warning:a.warning,dismissed:!0,verified:h.verified,verificationRequired:!h.verified,verificationWarning:h.verificationWarning,nextCommand:h.nextCommand,...t(b(h))});return d({session:n,sessionStore:s,command:o.command,positionals:o.positionals??[],flags:o.flags,result:g,responseData:g,actionStartedAt:l,actionFinishedAt:m})}async function y(e,t){let{req:n,sessionStore:r}=e,o=await p(t,n.flags,r,e.contextFromFlags,{interactiveOnly:!0});return i(o.snapshotQuality)?{verified:!1,verificationWarning:`React Native overlay dismissal could not be verified because the post-dismiss accessibility tree is unreadable. Use screenshot as visual truth.`,nextCommand:`agent-device screenshot`}:a(o.nodes).detected?{verified:!1,verificationWarning:`React Native overlay is still detected after dismissal. Use screenshot --overlay-refs for visual evidence and report the overlay instead of pressing the warning body.`,nextCommand:`agent-device screenshot --overlay-refs`}:{verified:!0}}function b(e){return e.verified?`React Native overlay dismiss action sent and verified gone`:`React Native overlay dismiss action sent, but verification still detects an overlay`}export{m as handleReactNativeCommands};
|
package/dist/src/record-trace.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{O as e}from"./snapshot-diagnostics.js";import{s as t}from"./context.js";import{c as n,h as r}from"./internal/daemon.js";import i from"node:fs";import a from"node:path";async function o(o){let{req:s,sessionName:c,sessionStore:l,logPath:u}=o,d=s.command;if(d===`record`)return n({req:s,sessionName:c,sessionStore:l,logPath:u});if(d===`trace`){let n=(s.positionals?.[0]??``).toLowerCase();if(![`start`,`stop`].includes(n))return t(`INVALID_ARGS`,`trace requires start|stop`);let o=l.get(c);if(!o)return t(`SESSION_NOT_FOUND`,`No active session`);if(n===`start`){if(o.trace)return t(`INVALID_ARGS`,`trace already in progress`);let n=s.positionals?.[1]??l.defaultTracePath(o),c=e.expandHome(n);return i.mkdirSync(a.dirname(c),{recursive:!0}),i.appendFileSync(c,``),o.trace={outPath:c,startedAt:Date.now()},r(l,o,s,d,{action:`start`,outPath:c}),{ok:!0,data:{trace:`started`,outPath:c}}}if(!o.trace)return t(`INVALID_ARGS`,`no active trace`);let u=o.trace.outPath;if(s.positionals?.[1]){let t=e.expandHome(s.positionals[1]);i.mkdirSync(a.dirname(t),{recursive:!0}),i.existsSync(u)?i.renameSync(u,t):i.appendFileSync(t,``),u=t}return o.trace=void 0,r(l,o,s,d,{action:`stop`,outPath:u}),{ok:!0,data:{trace:`stopped`,outPath:u}}}return null}export{o as handleRecordTraceCommands};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{rr as t}from"./tv-remote.js";import{c as n,d as r,o as i,s as a,v as o}from"./sdk-device.js";const s=[`android`,`apple`,`linux`],c={platform:`web`,id:`agent-browser-chrome`,name:`Agent Browser Chrome`,kind:`device`,target:`desktop`,booted:!0};function l(e){let t=d();for(let n of e){let e=f(n);t[e].available+=1,n.booted===!0&&(t[e].booted+=1)}return t}function u(e){return e.platform===`macos`||e.platform===`apple`&&e.target===`desktop`}function d(){return{android:{available:0,booted:0},apple:{available:0,booted:0},linux:{available:0,booted:0},web:{available:0,booted:0}}}function f(e){return a(e)||n(e)?`apple`:e.platform}async function p(e){if(e.platform===`web`)return[c];if(u(e)){let{listMacosDevices:e}=await import(`./devices.js`);return await e()}if(e.platform===`linux`){let{listLinuxDevices:e}=await import(`./devices3.js`);return await e()}if(e.platform===`android`){let{listAndroidDevices:t}=await import(`./logcat.js`).then(e=>e.c);return await t({serialAllowlist:m(e)})}if(e.platform){let{listAppleDevices:t}=await import(`./devices2.js`);return await t({simulatorSetPath:e.iosSimulatorSetPath,udid:e.udid})}let t=[];for(let n of s)try{t.push(...await p({...e,platform:n}))}catch{}return t}function m(e){let t=e.androidSerialAllowlist,n=e.serial?.trim();return n?t?new Set(t.includes(n)?[n]:[]):new Set([n]):t?new Set(t):void 0}const h=new Map;function g(e){for(let t of e.platforms){if(h.has(t))throw Error(`PlatformPlugin already registered for platform "${t}"`);h.set(t,e)}}function _(t){let n=h.get(t);if(!n)throw new e(`UNSUPPORTED_PLATFORM`,`Unsupported platform: ${t}`);return n}function v(e){return h.get(e)}const y={appAndDeviceLifecycle:!0,keyboard:!0,orientation:!0,physicalDeviceSurfaces:!1},b={ios:y,ipados:y,visionos:{appAndDeviceLifecycle:!0,keyboard:!0,orientation:!0,physicalDeviceSurfaces:!1},tvos:{appAndDeviceLifecycle:!0,keyboard:!1,orientation:!1,physicalDeviceSurfaces:!1},macos:{appAndDeviceLifecycle:!1,keyboard:!1,orientation:!1,physicalDeviceSurfaces:!0},watchos:{appAndDeviceLifecycle:!1,keyboard:!1,orientation:!1,physicalDeviceSurfaces:!1}};function x(e){return i(e.platform)?b[o(e)]:void 0}function S(e){return process.platform===`darwin`&&(n(e)||a(e)&&e.kind===`simulator`||e.platform===`android`&&e.kind===`emulator`)}function C(e){return e.platform===`web`||S(e)}const w=e=>{let t=x(e);return t?t.appAndDeviceLifecycle:!0},T=e=>{let t=x(e);return t?t.keyboard:e.platform===`android`},E=e=>{let t=x(e);return t?t.orientation:e.platform===`android`},D=e=>{let t=x(e);return t&&t.physicalDeviceSurfaces||e.kind===`simulator`},O=e=>e.platform===`android`||e.platform===`apple`&&o(e)===`ios`||D(e),k=e=>e.platform===`android`?e.target===`tv`:r(e),A=[{id:`apple`,platforms:[`apple`],familySelector:`apple`,capability:{bucket:`apple`,supportsByDefault:{[t.boot]:w,[t.install]:w,[t.reinstall]:w,[t.installFromSource]:w,[t.push]:w,[t.home]:w,[t.appSwitcher]:w,[t.clipboard]:e=>e.platform===`android`||e.platform===`linux`||D(e),[t.keyboard]:T,[t.orientation]:E,[t.tvRemote]:k,[t.alert]:O,[t.settings]:e=>e.platform===`android`||D(e),[t.audio]:C},unsupportedHintByDefault:{[t.tvRemote]:e=>e.platform===`android`?e.target===`tv`?void 0:`tv-remote is supported only on Android TV targets.`:x(e)?r(e)?void 0:`tv-remote is supported only on tvOS devices.`:void 0}},appLog:{resolveBackend:e=>n(e)?`macos`:e.kind===`device`?`ios-device`:`ios-simulator`},perf:{supportsMetrics:()=>!0,metricsSamplerTag:()=>`apple`},recording:{resolveBackendTag:e=>n(e)?`macos`:e.kind===`device`?`ios-device`:`ios-simulator`},providers:{platformGatedResolvers:[`appleRunnerProvider`,`appleToolProvider`]},createInteractor:async(e,t)=>{let{createAppleInteractor:n}=await import(`./interactor.js`);return n(e,t)},discoverDevices:async e=>{if(u(e)){let{listMacosDevices:e}=await import(`./devices.js`);return await e()}let{listAppleDevices:t}=await import(`./devices2.js`);return await t({simulatorSetPath:e.iosSimulatorSetPath,udid:e.udid})}},{id:`android`,platforms:[`android`],capability:{bucket:`android`,supportsByDefault:{[t.audio]:C,[t.tvRemote]:e=>e.target===`tv`},unsupportedHintByDefault:{[t.tvRemote]:e=>e.target===`tv`?void 0:`tv-remote is supported only on Android TV targets.`}},appLog:{resolveBackend:()=>`android`},perf:{supportsMetrics:()=>!0,metricsSamplerTag:()=>`android`},recording:{resolveBackendTag:()=>`android`},providers:{platformGatedResolvers:[`androidAdbProvider`]},createInteractor:async e=>{let{createAndroidInteractor:t}=await import(`./android.js`).then(e=>e.t);return t(e)},discoverDevices:async e=>{let{listAndroidDevices:t}=await import(`./logcat.js`).then(e=>e.c);return await t({serialAllowlist:m(e)})}},{id:`linux`,platforms:[`linux`],capability:{bucket:`linux`},providers:{platformGatedResolvers:[`linuxToolProvider`]},createInteractor:async()=>{let{createLinuxInteractor:e}=await import(`./linux.js`);return e()},discoverDevices:async()=>{let{listLinuxDevices:e}=await import(`./devices3.js`);return await e()}},{id:`web`,platforms:[`web`],capability:{bucket:`web`},recording:{resolveBackendTag:()=>`web`},providers:{platformGatedResolvers:[`webProvider`]},createInteractor:async()=>{let{createWebInteractor:e}=await import(`./web.js`);return e()},discoverDevices:async()=>[c]}];let j=!1;function M(){if(!j){for(let e of A)g(e);j=!0}}export{p as a,v as i,S as n,s as o,_ as r,l as s,M as t};
|