prowl-tools 0.1.4 → 0.1.5
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/NOTICE +10 -0
- package/README.md +277 -2
- package/dist/{chunk-ZEFVTKQT.js → chunk-2KD2XCTH.js} +2240 -213
- package/dist/chunk-2KD2XCTH.js.map +1 -0
- package/dist/{chunk-MBAIGNVO.js → chunk-ITOSUJCN.js} +39 -3
- package/dist/chunk-ITOSUJCN.js.map +1 -0
- package/dist/index.cjs +2411 -313
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +162 -67
- package/dist/index.js.map +1 -1
- package/dist/lib.cjs +2375 -244
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.d.cts +742 -4
- package/dist/lib.d.ts +742 -4
- package/dist/lib.js +126 -2
- package/dist/{loader-XMTDB6OL.js → loader-FCXPARP7.js} +2 -2
- package/package.json +5 -1
- package/dist/chunk-MBAIGNVO.js.map +0 -1
- package/dist/chunk-ZEFVTKQT.js.map +0 -1
- /package/dist/{loader-XMTDB6OL.js.map → loader-FCXPARP7.js.map} +0 -0
package/dist/lib.d.ts
CHANGED
|
@@ -22,7 +22,40 @@ type MacosTarget = {
|
|
|
22
22
|
type: "macos";
|
|
23
23
|
app: string;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Android native execution target (experimental, PROWL-058). `app` is an Android
|
|
27
|
+
* package name (e.g. `com.example.app`) or an absolute/relative path to an `.apk`
|
|
28
|
+
* file, which Prowl installs before launch. Optional `deviceSerial` selects one of
|
|
29
|
+
* several attached devices/emulators; `coldStart` opts into a deterministic
|
|
30
|
+
* `pm clear` before launch (default off). Android guardrails match package IDs
|
|
31
|
+
* or canonical full APK paths; APK package IDs are resolved before install.
|
|
32
|
+
*/
|
|
33
|
+
type AndroidTarget = {
|
|
34
|
+
type: "android";
|
|
35
|
+
app: string;
|
|
36
|
+
/** adb device serial to target when more than one device is attached. */
|
|
37
|
+
deviceSerial?: string;
|
|
38
|
+
/** Run `pm clear <package>` before launch for a deterministic cold start (default off). */
|
|
39
|
+
coldStart?: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* iOS simulator native execution target (experimental, PROWL-059). `app` is an
|
|
43
|
+
* iOS bundle identifier (e.g. `com.example.App`) or an absolute/relative path to
|
|
44
|
+
* a built `.app` bundle, which Prowl installs onto the simulator before launch.
|
|
45
|
+
* Optional `udid` selects a specific booted simulator; `coldStart` opts into an
|
|
46
|
+
* uninstall+reinstall before launch (default off, and only possible with a `.app`
|
|
47
|
+
* path). Real devices are out of scope (PROWL-062) — simulators only. iOS
|
|
48
|
+
* guardrails match bundle ids, the bundle name, or the canonical `.app` path.
|
|
49
|
+
*/
|
|
50
|
+
type IosTarget = {
|
|
51
|
+
type: "ios";
|
|
52
|
+
app: string;
|
|
53
|
+
/** UDID of the booted simulator to target when more than one is booted. */
|
|
54
|
+
udid?: string;
|
|
55
|
+
/** Uninstall+reinstall the app before launch for a deterministic cold start (default off). */
|
|
56
|
+
coldStart?: boolean;
|
|
57
|
+
};
|
|
58
|
+
type Target = WebTarget | MacosTarget | AndroidTarget | IosTarget;
|
|
26
59
|
type Config = {
|
|
27
60
|
target: Target;
|
|
28
61
|
browser: {
|
|
@@ -48,7 +81,7 @@ type Config = {
|
|
|
48
81
|
guardrails: {
|
|
49
82
|
maxSteps: number;
|
|
50
83
|
allowedDomains: string[];
|
|
51
|
-
/** Native scope analog of `allowedDomains`: allowed bundle IDs
|
|
84
|
+
/** Native scope analog of `allowedDomains`: allowed bundle/package IDs or canonical app artifact paths. */
|
|
52
85
|
allowedApps: string[];
|
|
53
86
|
forbiddenSelectors: string[];
|
|
54
87
|
selfHealing: boolean;
|
|
@@ -558,6 +591,538 @@ declare function launchMacSession(options: LaunchMacOptions): Promise<MacSession
|
|
|
558
591
|
/** Quit the target app (best effort) and shut the helper down. */
|
|
559
592
|
declare function closeMacSession(session: MacSession): Promise<void>;
|
|
560
593
|
|
|
594
|
+
/** A structured query the {@link AndroidAgentClient} resolves against the device. */
|
|
595
|
+
type AndroidQuery = {
|
|
596
|
+
by: "id";
|
|
597
|
+
value: string;
|
|
598
|
+
} | {
|
|
599
|
+
by: "accessibilityId";
|
|
600
|
+
value: string;
|
|
601
|
+
} | {
|
|
602
|
+
by: "role";
|
|
603
|
+
role: string;
|
|
604
|
+
name?: string;
|
|
605
|
+
} | {
|
|
606
|
+
by: "text";
|
|
607
|
+
value: string;
|
|
608
|
+
} | {
|
|
609
|
+
by: "focused";
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* A locator in the uiautomator2 server's native wire shape. The raw on-device
|
|
613
|
+
* server does NOT accept W3C `{using, value}` — that translation normally lives
|
|
614
|
+
* in Appium's driver layer, which we bypass — it requires `{strategy, selector}`
|
|
615
|
+
* (plus a `context` field, empty for a root-scoped search). Device-verified
|
|
616
|
+
* against appium-uiautomator2-server 10.6.2 (2026-08-19).
|
|
617
|
+
*/
|
|
618
|
+
type AndroidLocator = {
|
|
619
|
+
strategy: string;
|
|
620
|
+
selector: string;
|
|
621
|
+
context: string;
|
|
622
|
+
};
|
|
623
|
+
/**
|
|
624
|
+
* The semantic transport `AndroidDriver` talks to: element lookups return opaque
|
|
625
|
+
* element ids, and interactions take those ids. The HTTP/UiAutomator2
|
|
626
|
+
* implementation lives in {@link ./android-agent.js}; tests fake this interface.
|
|
627
|
+
*/
|
|
628
|
+
interface AndroidAgentClient {
|
|
629
|
+
/** Resolve the first element matching `query`, or null when none match. */
|
|
630
|
+
findElement(query: AndroidQuery): Promise<string | null>;
|
|
631
|
+
/** Resolve every element id matching `query` (empty when none match). */
|
|
632
|
+
findElements(query: AndroidQuery): Promise<string[]>;
|
|
633
|
+
click(elementId: string): Promise<void>;
|
|
634
|
+
/** Replace an element's text (unicode-safe; W3C `element/value`). */
|
|
635
|
+
setValue(elementId: string, text: string): Promise<void>;
|
|
636
|
+
getText(elementId: string): Promise<string | null>;
|
|
637
|
+
/** Dispatch a global key event by Android key code (goes to the focused view). */
|
|
638
|
+
pressKeyCode(keyCode: number): Promise<void>;
|
|
639
|
+
/** Capture the current screen as PNG bytes. */
|
|
640
|
+
screenshotPng(): Promise<Buffer>;
|
|
641
|
+
close(): Promise<void>;
|
|
642
|
+
}
|
|
643
|
+
type AndroidDriverOptions = {
|
|
644
|
+
/** Package name, used only for the informational `currentUrl()` value. */
|
|
645
|
+
appLabel?: string;
|
|
646
|
+
};
|
|
647
|
+
/**
|
|
648
|
+
* Android key names accepted by the `press` step, mapped to KeyEvent key codes.
|
|
649
|
+
* Names are matched case-insensitively.
|
|
650
|
+
*/
|
|
651
|
+
declare const ANDROID_KEYCODES: Readonly<Record<string, number>>;
|
|
652
|
+
/** Escape a string for embedding inside a `new UiSelector()...("...")` argument. */
|
|
653
|
+
declare function escapeUiSelectorArg(value: string): string;
|
|
654
|
+
/** Parse a Prowl selector string into an {@link AndroidQuery}. Bare text matches by text. */
|
|
655
|
+
declare function parseAndroidSelector(selector: string): AndroidQuery;
|
|
656
|
+
/**
|
|
657
|
+
* Translate an {@link AndroidQuery} into the uiautomator2 server's native
|
|
658
|
+
* locator shape. `id`/`accessibility id` are native strategies;
|
|
659
|
+
* text/role(+name)/focused compose a `-android uiautomator` `UiSelector`.
|
|
660
|
+
* `appPackage` qualifies bare `id=` names ({@link qualifyResourceId}).
|
|
661
|
+
*/
|
|
662
|
+
declare function androidQueryToLocator(query: AndroidQuery, options?: {
|
|
663
|
+
appPackage?: string;
|
|
664
|
+
}): AndroidLocator;
|
|
665
|
+
/** The literal text a `text=` selector matches, else null (mirrors the web driver). */
|
|
666
|
+
declare function unwrapAndroidTextSelector(selector: string): string | null;
|
|
667
|
+
/** Wrap a live {@link AndroidAgentClient} as a {@link SessionDriver}. */
|
|
668
|
+
declare function createAndroidDriver(client: AndroidAgentClient, options?: AndroidDriverOptions): SessionDriver;
|
|
669
|
+
|
|
670
|
+
/** Result of one adb invocation. */
|
|
671
|
+
type AdbResult = {
|
|
672
|
+
stdout: string;
|
|
673
|
+
stderr: string;
|
|
674
|
+
code: number;
|
|
675
|
+
};
|
|
676
|
+
/** Runs one adb command to completion and resolves with its captured output. */
|
|
677
|
+
type AdbRunner = (args: string[], options?: {
|
|
678
|
+
timeoutMs?: number;
|
|
679
|
+
}) => Promise<AdbResult>;
|
|
680
|
+
/** A handle to a spawned long-running adb process (the instrumentation server). */
|
|
681
|
+
type AdbProcessHandle = {
|
|
682
|
+
kill(): void;
|
|
683
|
+
};
|
|
684
|
+
/** Spawns a long-running adb command (e.g. `am instrument -w`) in the background. */
|
|
685
|
+
type AdbSpawner = (args: string[]) => AdbProcessHandle;
|
|
686
|
+
/** One row of `adb devices -l`. */
|
|
687
|
+
type AdbDevice = {
|
|
688
|
+
serial: string;
|
|
689
|
+
state: string;
|
|
690
|
+
description: Record<string, string>;
|
|
691
|
+
};
|
|
692
|
+
/**
|
|
693
|
+
* Parse `adb devices -l` output into structured rows. The header line
|
|
694
|
+
* (`List of devices attached`) and blank lines are skipped.
|
|
695
|
+
*/
|
|
696
|
+
declare function parseAdbDevices(stdout: string): AdbDevice[];
|
|
697
|
+
/** Devices that are fully booted and usable (`device` state). */
|
|
698
|
+
declare function bootedDevices(devices: AdbDevice[]): AdbDevice[];
|
|
699
|
+
/**
|
|
700
|
+
* Choose which device to drive. With `requested` set it must be attached and
|
|
701
|
+
* booted. Otherwise exactly one booted device is required; zero or many raise an
|
|
702
|
+
* actionable error listing what was found.
|
|
703
|
+
*/
|
|
704
|
+
declare function selectDeviceSerial(devices: AdbDevice[], requested?: string): string;
|
|
705
|
+
/** List attached devices via `adb devices -l`. */
|
|
706
|
+
declare function listDevices(runner: AdbRunner): Promise<AdbDevice[]>;
|
|
707
|
+
/**
|
|
708
|
+
* Parse the local port `adb forward tcp:0 tcp:<remote>` prints (dynamic port
|
|
709
|
+
* allocation). adb echoes the chosen local port on stdout.
|
|
710
|
+
*/
|
|
711
|
+
declare function parseForwardPort(stdout: string): number;
|
|
712
|
+
/** Parse the package name out of `aapt dump badging <apk>` output. */
|
|
713
|
+
declare function parseAaptPackage(stdout: string): string | null;
|
|
714
|
+
|
|
715
|
+
/** The remote port the uiautomator2 server listens on inside the device. */
|
|
716
|
+
declare const UIA2_REMOTE_PORT = 6790;
|
|
717
|
+
/** Locations of the two prebuilt agent APKs. */
|
|
718
|
+
type AgentApks = {
|
|
719
|
+
serverApk: string;
|
|
720
|
+
testApk: string;
|
|
721
|
+
};
|
|
722
|
+
/** Establishes a live {@link AndroidAgentClient} against a forwarded local port. */
|
|
723
|
+
type AgentConnector = (options: {
|
|
724
|
+
host: string;
|
|
725
|
+
port: number;
|
|
726
|
+
requestTimeoutMs: number;
|
|
727
|
+
readyDeadlineMs: number;
|
|
728
|
+
/** Target app's package name; qualifies bare `id=` selectors on the device. */
|
|
729
|
+
appPackage?: string;
|
|
730
|
+
}) => Promise<AndroidAgentClient>;
|
|
731
|
+
/** Resolve a package name from an `.apk` file, or null when it can't be determined. */
|
|
732
|
+
type AaptResolver = (apkPath: string) => Promise<string | null>;
|
|
733
|
+
/**
|
|
734
|
+
* Resolve the two agent APKs shipped inside `appium-uiautomator2-server`. They
|
|
735
|
+
* live under the package's `apks/` folder; the server APK is version-stamped.
|
|
736
|
+
*/
|
|
737
|
+
declare function resolveAgentApks(requireFn?: NodeRequire): AgentApks;
|
|
738
|
+
/** Default connector: builds the HTTP transport, waits for readiness, opens a session. */
|
|
739
|
+
declare const defaultAgentConnector: AgentConnector;
|
|
740
|
+
type AndroidSession = {
|
|
741
|
+
client: AndroidAgentClient;
|
|
742
|
+
driver: SessionDriver;
|
|
743
|
+
/** The resolved package name being driven. */
|
|
744
|
+
package: string;
|
|
745
|
+
/** The adb serial of the device being driven. */
|
|
746
|
+
serial: string;
|
|
747
|
+
/** Tear down the session, agent, port forward, and app (best effort). */
|
|
748
|
+
teardown(): Promise<void>;
|
|
749
|
+
};
|
|
750
|
+
type LaunchAndroidOptions = {
|
|
751
|
+
/** Package name or `.apk` path. */
|
|
752
|
+
app: string;
|
|
753
|
+
/** adb serial when more than one device is attached. */
|
|
754
|
+
deviceSerial?: string;
|
|
755
|
+
/** `pm clear` the package before launch for a deterministic cold start. */
|
|
756
|
+
coldStart?: boolean;
|
|
757
|
+
timeoutMs?: number;
|
|
758
|
+
runner?: AdbRunner;
|
|
759
|
+
spawner?: AdbSpawner;
|
|
760
|
+
agentConnector?: AgentConnector;
|
|
761
|
+
apks?: AgentApks;
|
|
762
|
+
aaptResolver?: AaptResolver;
|
|
763
|
+
/** Optional app scope guardrail from config.guardrails.allowedApps. */
|
|
764
|
+
allowedApps?: string[];
|
|
765
|
+
};
|
|
766
|
+
/**
|
|
767
|
+
* Preflight, install, launch, and attach the uiautomator2 agent, returning a
|
|
768
|
+
* live {@link AndroidSession}. Actionable errors cover each failure mode: adb
|
|
769
|
+
* missing / no booted device (device selection), agent unreachable (readiness).
|
|
770
|
+
*/
|
|
771
|
+
declare function launchAndroidSession(options: LaunchAndroidOptions): Promise<AndroidSession>;
|
|
772
|
+
/** Tear down an Android session (agent session, instrumentation, forward, app). */
|
|
773
|
+
declare function closeAndroidSession(session: AndroidSession): Promise<void>;
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* PROWL-058 / ARCH-009 — HTTP/JSON transport for the on-device uiautomator2 agent.
|
|
777
|
+
*
|
|
778
|
+
* `appium-uiautomator2-server` exposes W3C-WebDriver-shaped endpoints over plain
|
|
779
|
+
* HTTP. This module speaks them with the global `fetch` (no heavy WebDriver SDK,
|
|
780
|
+
* per the `ai.ts` ethos), mirroring the mac-helper client's ergonomics: a
|
|
781
|
+
* per-request deadline via `AbortController`, and cleanup on
|
|
782
|
+
* every path. It exposes the semantic {@link AndroidAgentClient} the driver
|
|
783
|
+
* consumes; tests fake either the `fetch` implementation or the client itself.
|
|
784
|
+
*/
|
|
785
|
+
|
|
786
|
+
/** The subset of `fetch` this module uses; overridable in tests. */
|
|
787
|
+
type FetchLike$1 = (url: string, init: RequestInit) => Promise<Response>;
|
|
788
|
+
/** Default per-request deadline for the agent transport. */
|
|
789
|
+
declare const DEFAULT_AGENT_REQUEST_TIMEOUT_MS = 30000;
|
|
790
|
+
type Uia2TransportOptions = {
|
|
791
|
+
/** Base URL including the `/wd/hub` prefix, e.g. `http://127.0.0.1:6790/wd/hub`. */
|
|
792
|
+
baseUrl: string;
|
|
793
|
+
requestTimeoutMs?: number;
|
|
794
|
+
fetchImpl?: FetchLike$1;
|
|
795
|
+
};
|
|
796
|
+
/** An HTTP-level failure from the agent, carrying the status and parsed body. */
|
|
797
|
+
declare class Uia2HttpError extends Error {
|
|
798
|
+
readonly status: number;
|
|
799
|
+
readonly webdriverError?: string | undefined;
|
|
800
|
+
constructor(message: string, status: number, webdriverError?: string | undefined);
|
|
801
|
+
}
|
|
802
|
+
/** Low-level request/response transport with a per-request deadline. */
|
|
803
|
+
declare class Uia2Transport {
|
|
804
|
+
private readonly baseUrl;
|
|
805
|
+
private readonly requestTimeoutMs;
|
|
806
|
+
private readonly fetchImpl;
|
|
807
|
+
constructor(options: Uia2TransportOptions);
|
|
808
|
+
/**
|
|
809
|
+
* Send one request and return the parsed `value` field. Rejects with a
|
|
810
|
+
* {@link Uia2HttpError} on a non-2xx response, or a timeout error when the
|
|
811
|
+
* per-request deadline elapses.
|
|
812
|
+
*/
|
|
813
|
+
request(method: string, path: string, body?: unknown, timeoutMs?: number): Promise<unknown>;
|
|
814
|
+
}
|
|
815
|
+
/** Extract an element id from a W3C element-reference object, or null. */
|
|
816
|
+
declare function extractElementId(value: unknown): string | null;
|
|
817
|
+
/**
|
|
818
|
+
* Create a uiautomator2 session and return its id. Uses the W3C `capabilities`
|
|
819
|
+
* envelope; the server ignores the empty match set and starts a default session.
|
|
820
|
+
*/
|
|
821
|
+
declare function createUia2Session(transport: Uia2Transport): Promise<string>;
|
|
822
|
+
/** Poll `GET /status` until the agent reports ready or the deadline elapses. */
|
|
823
|
+
declare function waitForAgentReady(transport: Uia2Transport, options?: {
|
|
824
|
+
deadlineMs: number;
|
|
825
|
+
intervalMs?: number;
|
|
826
|
+
}): Promise<void>;
|
|
827
|
+
/**
|
|
828
|
+
* Build the semantic {@link AndroidAgentClient} over a live session. `close`
|
|
829
|
+
* deletes the session (best effort); the transport itself is stateless.
|
|
830
|
+
*/
|
|
831
|
+
declare function createUia2AgentClient(transport: Uia2Transport, sessionId: string, options?: {
|
|
832
|
+
appPackage?: string;
|
|
833
|
+
}): AndroidAgentClient;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* PROWL-059 / ARCH-010 — iOS simulator implementation of {@link SessionDriver}.
|
|
837
|
+
*
|
|
838
|
+
* `IosDriver` drives a native iOS app through a prebuilt WebDriverAgent (WDA)
|
|
839
|
+
* runner over its W3C-shaped HTTP/JSON API ({@link IosAgentClient}). Like the
|
|
840
|
+
* macOS and Android drivers it implements only the portable subset of the driver
|
|
841
|
+
* surface — its `capabilities` set is honest: `query`, `interact`, `wait`,
|
|
842
|
+
* `screenshot`. Web-only verbs (navigation, network, dialogs, files, downloads,
|
|
843
|
+
* script evaluation) are unsupported stubs; the runner never reaches them because
|
|
844
|
+
* both the target step-compatibility check and the runtime capability gate reject
|
|
845
|
+
* web-only steps for native targets.
|
|
846
|
+
*
|
|
847
|
+
* Screenshots are captured via `simctl` (injected as `captureScreenshot`), not
|
|
848
|
+
* WDA, so artifacts still work even if the agent wedges.
|
|
849
|
+
*
|
|
850
|
+
* Selector dialect (parsed here into an {@link IosQuery}; the agent then matches
|
|
851
|
+
* on the simulator). Semantics mirror the macOS/Android drivers so `id=`/`label=`/
|
|
852
|
+
* `text=`/`role=` mean the same thing across native targets (PROWL-060 will unify
|
|
853
|
+
* the engines later):
|
|
854
|
+
* id=save → accessibility id (accessibilityIdentifier / name)
|
|
855
|
+
* label="Submit" → predicate `label == "Submit"` (exact)
|
|
856
|
+
* role=XCUIElementTypeButton → element class (shorthand `Button` is accepted too)
|
|
857
|
+
* role=Button[name="Save"] → class + visible text (label/value substring)
|
|
858
|
+
* text="Save" | Save → label/value substring
|
|
859
|
+
* :focus → predicate `hasKeyboardFocus == 1`
|
|
860
|
+
*/
|
|
861
|
+
|
|
862
|
+
/** A structured query the {@link IosAgentClient} resolves against the simulator. */
|
|
863
|
+
type IosQuery = {
|
|
864
|
+
by: "accessibilityId";
|
|
865
|
+
value: string;
|
|
866
|
+
} | {
|
|
867
|
+
by: "label";
|
|
868
|
+
value: string;
|
|
869
|
+
} | {
|
|
870
|
+
by: "role";
|
|
871
|
+
role: string;
|
|
872
|
+
name?: string;
|
|
873
|
+
} | {
|
|
874
|
+
by: "text";
|
|
875
|
+
value: string;
|
|
876
|
+
} | {
|
|
877
|
+
by: "focused";
|
|
878
|
+
};
|
|
879
|
+
/** A WDA locator strategy ({@code using}) + its value, as the agent expects. */
|
|
880
|
+
type IosLocator = {
|
|
881
|
+
using: string;
|
|
882
|
+
value: string;
|
|
883
|
+
};
|
|
884
|
+
/**
|
|
885
|
+
* The semantic transport `IosDriver` talks to: element lookups return opaque
|
|
886
|
+
* element ids, and interactions take those ids. The HTTP/WDA implementation lives
|
|
887
|
+
* in {@link ./ios-agent.js}; tests fake this interface.
|
|
888
|
+
*/
|
|
889
|
+
interface IosAgentClient {
|
|
890
|
+
/** Resolve the first element matching `query`, or null when none match. */
|
|
891
|
+
findElement(query: IosQuery): Promise<string | null>;
|
|
892
|
+
/** Resolve every element id matching `query` (empty when none match). */
|
|
893
|
+
findElements(query: IosQuery): Promise<string[]>;
|
|
894
|
+
click(elementId: string): Promise<void>;
|
|
895
|
+
/** Replace an element's text (W3C `element/value`). */
|
|
896
|
+
setValue(elementId: string, text: string): Promise<void>;
|
|
897
|
+
getText(elementId: string): Promise<string | null>;
|
|
898
|
+
/** Send raw key sequences to the focused element (WDA `/wda/keys`). */
|
|
899
|
+
sendKeys(keys: string[]): Promise<void>;
|
|
900
|
+
/** Return to the springboard home screen (WDA `/wda/homescreen`). */
|
|
901
|
+
homescreen(): Promise<void>;
|
|
902
|
+
close(): Promise<void>;
|
|
903
|
+
}
|
|
904
|
+
type IosDriverOptions = {
|
|
905
|
+
/** Bundle id, used only for the informational `currentUrl()` value. */
|
|
906
|
+
appLabel?: string;
|
|
907
|
+
/** Capture a PNG screenshot to `path` (injected simctl capture). */
|
|
908
|
+
captureScreenshot: (path: string) => Promise<void>;
|
|
909
|
+
};
|
|
910
|
+
/**
|
|
911
|
+
* Key names the `press` step supports on iOS, sorted for error messages. `enter`/
|
|
912
|
+
* `return` send a newline, `delete`/`backspace` send a backspace (both via WDA's
|
|
913
|
+
* key endpoint), and `home` returns to the springboard.
|
|
914
|
+
*/
|
|
915
|
+
declare const IOS_PRESS_KEYS: readonly string[];
|
|
916
|
+
/** Escape a string for embedding inside a double-quoted NSPredicate string literal. */
|
|
917
|
+
declare function escapePredicateArg(value: string): string;
|
|
918
|
+
/** Prefix `XCUIElementType` onto a role shorthand (e.g. `Button`) when missing. */
|
|
919
|
+
declare function normalizeXcuiClassName(role: string): string;
|
|
920
|
+
/** Parse a Prowl selector string into an {@link IosQuery}. Bare text matches by text. */
|
|
921
|
+
declare function parseIosSelector(selector: string): IosQuery;
|
|
922
|
+
/**
|
|
923
|
+
* Translate an {@link IosQuery} into a WDA locator strategy. `id` uses the native
|
|
924
|
+
* `accessibility id` strategy and bare roles use `class name`; everything else
|
|
925
|
+
* composes an NSPredicate string (WDA's `predicate string` strategy).
|
|
926
|
+
*/
|
|
927
|
+
declare function iosQueryToLocator(query: IosQuery): IosLocator;
|
|
928
|
+
/** The literal text a `text=` selector matches, else null (mirrors the web driver). */
|
|
929
|
+
declare function unwrapIosTextSelector(selector: string): string | null;
|
|
930
|
+
/** Wrap a live {@link IosAgentClient} as a {@link SessionDriver}. */
|
|
931
|
+
declare function createIosDriver(client: IosAgentClient, options: IosDriverOptions): SessionDriver;
|
|
932
|
+
|
|
933
|
+
/** Result of one `xcrun` invocation. */
|
|
934
|
+
type SimctlResult = {
|
|
935
|
+
stdout: string;
|
|
936
|
+
stderr: string;
|
|
937
|
+
code: number;
|
|
938
|
+
};
|
|
939
|
+
/** Runs one `xcrun <args>` command to completion and resolves with its output. */
|
|
940
|
+
type SimctlRunner = (args: string[], options?: {
|
|
941
|
+
timeoutMs?: number;
|
|
942
|
+
env?: NodeJS.ProcessEnv;
|
|
943
|
+
}) => Promise<SimctlResult>;
|
|
944
|
+
/** One simulator device from `simctl list devices --json`. */
|
|
945
|
+
type SimDevice = {
|
|
946
|
+
udid: string;
|
|
947
|
+
name: string;
|
|
948
|
+
state: string;
|
|
949
|
+
runtime: string;
|
|
950
|
+
isAvailable: boolean;
|
|
951
|
+
};
|
|
952
|
+
type SimulatorReservation = {
|
|
953
|
+
udid: string;
|
|
954
|
+
release(): Promise<void>;
|
|
955
|
+
};
|
|
956
|
+
type ReserveSimulatorOptions = {
|
|
957
|
+
/** Override the lock directory root; intended for tests. */
|
|
958
|
+
lockRoot?: string;
|
|
959
|
+
};
|
|
960
|
+
declare const DEFAULT_SIMULATOR_LOCK_ROOT: string;
|
|
961
|
+
/**
|
|
962
|
+
* Reserve a simulator UDID across processes. The lock is held until `release` is
|
|
963
|
+
* called, preventing one session's teardown from terminating another session's
|
|
964
|
+
* WDA runner or target app on the same simulator.
|
|
965
|
+
*/
|
|
966
|
+
declare function reserveSimulatorUdid(udid: string, options?: ReserveSimulatorOptions): Promise<SimulatorReservation>;
|
|
967
|
+
/**
|
|
968
|
+
* Allocate a free local TCP port by binding to :0 and releasing it. The returned
|
|
969
|
+
* port is advisory after release; callers that hand it to another process must
|
|
970
|
+
* handle a later bind/readiness failure.
|
|
971
|
+
*/
|
|
972
|
+
declare function findFreePort(): Promise<number>;
|
|
973
|
+
/**
|
|
974
|
+
* Parse `simctl list devices --json` into a flat device list. The JSON maps
|
|
975
|
+
* runtime identifiers to arrays of devices; the runtime is folded into each row.
|
|
976
|
+
*/
|
|
977
|
+
declare function parseSimctlDevices(json: string): SimDevice[];
|
|
978
|
+
/** Simulators that are currently booted. */
|
|
979
|
+
declare function bootedSimulators(devices: SimDevice[]): SimDevice[];
|
|
980
|
+
/**
|
|
981
|
+
* Choose which simulator to drive. With `requested` set it must exist and be
|
|
982
|
+
* booted. Otherwise exactly one booted simulator is required; zero or many raise
|
|
983
|
+
* an actionable error listing what was found.
|
|
984
|
+
*/
|
|
985
|
+
declare function selectSimulatorUdid(devices: SimDevice[], requested?: string): string;
|
|
986
|
+
/** List all simulators via `simctl list devices --json`. */
|
|
987
|
+
declare function listSimulators(runner: SimctlRunner): Promise<SimDevice[]>;
|
|
988
|
+
/** Parse the `x.y[.z]` version out of `xcodebuild -version` output. */
|
|
989
|
+
declare function parseXcodeVersion(stdout: string): string | null;
|
|
990
|
+
|
|
991
|
+
/** Bundle id of the prebuilt WebDriverAgent runner (its xctest host app). */
|
|
992
|
+
declare const WDA_RUNNER_BUNDLE_ID = "com.facebook.WebDriverAgentRunner.xctrunner";
|
|
993
|
+
/** The runner `.app` produced by `xcodebuild build-for-testing`. */
|
|
994
|
+
declare const WDA_RUNNER_APP_NAME = "WebDriverAgentRunner-Runner.app";
|
|
995
|
+
/** Establishes a live {@link IosAgentClient} against a running WDA HTTP server. */
|
|
996
|
+
type IosAgentConnector = (options: {
|
|
997
|
+
host: string;
|
|
998
|
+
port: number;
|
|
999
|
+
bundleId: string;
|
|
1000
|
+
requestTimeoutMs: number;
|
|
1001
|
+
readyDeadlineMs: number;
|
|
1002
|
+
}) => Promise<IosAgentClient>;
|
|
1003
|
+
/** Default connector: builds the HTTP transport, waits for readiness, opens a session. */
|
|
1004
|
+
declare const defaultIosAgentConnector: IosAgentConnector;
|
|
1005
|
+
/** Resolve the WDA Xcode project bundled inside `appium-webdriveragent`. */
|
|
1006
|
+
declare function resolveWdaProject(requireFn?: NodeRequire): {
|
|
1007
|
+
projectPath: string;
|
|
1008
|
+
version: string;
|
|
1009
|
+
};
|
|
1010
|
+
/** Cache directory for a built WDA runner, keyed on the WDA + Xcode versions. */
|
|
1011
|
+
declare function wdaCacheDir(wdaVersion: string, xcode: string, homeDir?: string): string;
|
|
1012
|
+
type ResolveWdaRunnerOptions = {
|
|
1013
|
+
runner?: SimctlRunner;
|
|
1014
|
+
env?: NodeJS.ProcessEnv;
|
|
1015
|
+
homeDir?: string;
|
|
1016
|
+
requireFn?: NodeRequire;
|
|
1017
|
+
/** One-line progress notice sink (defaults to stderr). */
|
|
1018
|
+
logger?: (message: string) => void;
|
|
1019
|
+
};
|
|
1020
|
+
/**
|
|
1021
|
+
* Resolve a WebDriverAgent runner `.app`. Order: (a) the `PROWL_WDA_RUNNER` env
|
|
1022
|
+
* override; (b) a previously built runner in the version-keyed cache; (c) a
|
|
1023
|
+
* one-time `xcodebuild build-for-testing` that populates the cache. Simulators
|
|
1024
|
+
* need no code signing. Throws actionable errors when Xcode is missing or the
|
|
1025
|
+
* build fails.
|
|
1026
|
+
*/
|
|
1027
|
+
declare function resolveWdaRunner(options?: ResolveWdaRunnerOptions): Promise<string>;
|
|
1028
|
+
type IosSession = {
|
|
1029
|
+
client: IosAgentClient;
|
|
1030
|
+
driver: SessionDriver;
|
|
1031
|
+
/** The resolved bundle id being driven. */
|
|
1032
|
+
bundleId: string;
|
|
1033
|
+
/** The UDID of the simulator being driven. */
|
|
1034
|
+
udid: string;
|
|
1035
|
+
/** Tear down the session, WDA runner, and target app (best effort). */
|
|
1036
|
+
teardown(): Promise<void>;
|
|
1037
|
+
};
|
|
1038
|
+
type LaunchIosOptions = {
|
|
1039
|
+
/** Bundle id or `.app` path. */
|
|
1040
|
+
app: string;
|
|
1041
|
+
/** Simulator UDID when more than one is booted. */
|
|
1042
|
+
udid?: string;
|
|
1043
|
+
/** Uninstall+reinstall the app before launch (requires a `.app` path). */
|
|
1044
|
+
coldStart?: boolean;
|
|
1045
|
+
timeoutMs?: number;
|
|
1046
|
+
runner?: SimctlRunner;
|
|
1047
|
+
portAllocator?: () => Promise<number>;
|
|
1048
|
+
agentConnector?: IosAgentConnector;
|
|
1049
|
+
/** Skip WDA build/resolution by supplying the runner app path directly. */
|
|
1050
|
+
wdaRunnerApp?: string;
|
|
1051
|
+
/** Optional app scope guardrail from config.guardrails.allowedApps. */
|
|
1052
|
+
allowedApps?: string[];
|
|
1053
|
+
/** Override the simulator lock root; intended for tests. */
|
|
1054
|
+
simulatorLockRoot?: string;
|
|
1055
|
+
logger?: (message: string) => void;
|
|
1056
|
+
};
|
|
1057
|
+
/**
|
|
1058
|
+
* Preflight, install, launch, and attach WDA, returning a live {@link IosSession}.
|
|
1059
|
+
* Actionable errors cover each failure mode: Xcode/simctl missing, no booted
|
|
1060
|
+
* simulator (device selection), WDA build failures, agent unreachable (readiness).
|
|
1061
|
+
*/
|
|
1062
|
+
declare function launchIosSession(options: LaunchIosOptions): Promise<IosSession>;
|
|
1063
|
+
/** Tear down an iOS session (agent session, WDA runner, target app). */
|
|
1064
|
+
declare function closeIosSession(session: IosSession): Promise<void>;
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* PROWL-059 / ARCH-010 — HTTP/JSON transport for the on-simulator WebDriverAgent.
|
|
1068
|
+
*
|
|
1069
|
+
* WebDriverAgent (WDA) exposes W3C-WebDriver-shaped endpoints over plain HTTP. On
|
|
1070
|
+
* a simulator it is reachable directly at `http://127.0.0.1:<port>` (no tunnel),
|
|
1071
|
+
* so this module speaks it with the global `fetch` (no heavy WebDriver SDK, per
|
|
1072
|
+
* the `ai.ts` ethos), mirroring the Android agent's ergonomics: a per-request
|
|
1073
|
+
* deadline via `AbortController`, unref'd timers, and W3C element-key extraction.
|
|
1074
|
+
* It exposes the semantic {@link IosAgentClient} the driver consumes; tests fake
|
|
1075
|
+
* either the `fetch` implementation or the client itself.
|
|
1076
|
+
*/
|
|
1077
|
+
|
|
1078
|
+
/** The subset of `fetch` this module uses; overridable in tests. */
|
|
1079
|
+
type FetchLike = (url: string, init: RequestInit) => Promise<Response>;
|
|
1080
|
+
/** Default per-request deadline for the agent transport. */
|
|
1081
|
+
declare const DEFAULT_WDA_REQUEST_TIMEOUT_MS = 30000;
|
|
1082
|
+
type WdaTransportOptions = {
|
|
1083
|
+
/** Base URL, e.g. `http://127.0.0.1:8100`. */
|
|
1084
|
+
baseUrl: string;
|
|
1085
|
+
requestTimeoutMs?: number;
|
|
1086
|
+
fetchImpl?: FetchLike;
|
|
1087
|
+
};
|
|
1088
|
+
/** An HTTP-level failure from WDA, carrying the status and parsed body. */
|
|
1089
|
+
declare class WdaHttpError extends Error {
|
|
1090
|
+
readonly status: number;
|
|
1091
|
+
readonly webdriverError?: string | undefined;
|
|
1092
|
+
constructor(message: string, status: number, webdriverError?: string | undefined);
|
|
1093
|
+
}
|
|
1094
|
+
/** Low-level request/response transport with a per-request deadline. */
|
|
1095
|
+
declare class WdaTransport {
|
|
1096
|
+
private readonly baseUrl;
|
|
1097
|
+
private readonly requestTimeoutMs;
|
|
1098
|
+
private readonly fetchImpl;
|
|
1099
|
+
constructor(options: WdaTransportOptions);
|
|
1100
|
+
/**
|
|
1101
|
+
* Send one request and return the full parsed JSON body. Rejects with a
|
|
1102
|
+
* {@link WdaHttpError} on a non-2xx response, or a timeout error when the
|
|
1103
|
+
* per-request deadline elapses.
|
|
1104
|
+
*/
|
|
1105
|
+
requestFull(method: string, path: string, body?: unknown, timeoutMs?: number): Promise<unknown>;
|
|
1106
|
+
/** Like {@link requestFull} but returns just the `value` field. */
|
|
1107
|
+
request(method: string, path: string, body?: unknown, timeoutMs?: number): Promise<unknown>;
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Create a WDA session bound to `bundleId` and return its id. WDA activates the
|
|
1111
|
+
* app under test named in `alwaysMatch.bundleId`. The session id may arrive at
|
|
1112
|
+
* the envelope root or inside `value`, so both are checked.
|
|
1113
|
+
*/
|
|
1114
|
+
declare function createWdaSession(transport: WdaTransport, bundleId: string): Promise<string>;
|
|
1115
|
+
/** Poll `GET /status` until WDA reports ready or the deadline elapses. */
|
|
1116
|
+
declare function waitForWdaReady(transport: WdaTransport, options?: {
|
|
1117
|
+
deadlineMs: number;
|
|
1118
|
+
intervalMs?: number;
|
|
1119
|
+
}): Promise<void>;
|
|
1120
|
+
/**
|
|
1121
|
+
* Build the semantic {@link IosAgentClient} over a live session. `close` deletes
|
|
1122
|
+
* the session (best effort); the transport itself is stateless.
|
|
1123
|
+
*/
|
|
1124
|
+
declare function createWdaAgentClient(transport: WdaTransport, sessionId: string): IosAgentClient;
|
|
1125
|
+
|
|
561
1126
|
/**
|
|
562
1127
|
* PROWL-048 / ARCH-002 — target ⇄ step compatibility.
|
|
563
1128
|
*
|
|
@@ -579,9 +1144,18 @@ declare function webOnlyReason(step: Step): string | null;
|
|
|
579
1144
|
/**
|
|
580
1145
|
* Throw if any step in `steps` (recursing into `if`/`repeat` bodies) is not
|
|
581
1146
|
* supported by `target`. `runHunt` references are validated when the referenced
|
|
582
|
-
* hunt itself runs. No-op for the web target
|
|
1147
|
+
* hunt itself runs. No-op for the web target; every native target (macOS,
|
|
1148
|
+
* Android, iOS) rejects the same web-only step vocabulary.
|
|
583
1149
|
*/
|
|
584
1150
|
declare function assertStepsSupportedByTarget(steps: Step[], target: Target["type"]): void;
|
|
1151
|
+
/** Read the bundle id from an iOS `.app` (root `Info.plist`), or null. */
|
|
1152
|
+
declare function readIosBundleIdentifier(appPath: string): string | null;
|
|
1153
|
+
/**
|
|
1154
|
+
* Accepted identities for an iOS target app. A bare bundle id matches itself; a
|
|
1155
|
+
* `.app` path is authorized by its path, bundle name, or the `CFBundleIdentifier`
|
|
1156
|
+
* read from the bundle's root `Info.plist`.
|
|
1157
|
+
*/
|
|
1158
|
+
declare function iosAppAllowedIdentities(app: string): string[];
|
|
585
1159
|
/**
|
|
586
1160
|
* Native scope guardrail: if `allowedApps` is non-empty it must include an
|
|
587
1161
|
* accepted identity for the target app: bundle id, app bundle name, or `.app`
|
|
@@ -589,6 +1163,25 @@ declare function assertStepsSupportedByTarget(steps: Step[], target: Target["typ
|
|
|
589
1163
|
* allowed — mirroring how allowedDomains auto-includes the web target's host.
|
|
590
1164
|
*/
|
|
591
1165
|
declare function assertTargetAppAllowed(allowedApps: string[], app: string): void;
|
|
1166
|
+
/**
|
|
1167
|
+
* iOS scope guardrail (PROWL-059): mirrors {@link assertTargetAppAllowed} but
|
|
1168
|
+
* resolves identities via {@link iosAppAllowedIdentities} (bundle id or `.app`
|
|
1169
|
+
* path with the id read from the bundle's root `Info.plist`).
|
|
1170
|
+
*/
|
|
1171
|
+
declare function assertIosAppAllowed(allowedApps: string[], app: string): void;
|
|
1172
|
+
/**
|
|
1173
|
+
* Accepted identities for an Android target app. A bare package name matches
|
|
1174
|
+
* itself. An `.apk` path is authorized only by its canonical full path; pass the
|
|
1175
|
+
* resolved package name when validating an APK after `aapt` resolution so
|
|
1176
|
+
* package-ID allowlists can authorize it before install.
|
|
1177
|
+
*/
|
|
1178
|
+
declare function androidAppAllowedIdentities(app: string, resolvedPackage?: string): string[];
|
|
1179
|
+
/**
|
|
1180
|
+
* Android scope guardrail (PROWL-058): mirrors {@link assertTargetAppAllowed} but
|
|
1181
|
+
* resolves identities via {@link androidAppAllowedIdentities} (package name or
|
|
1182
|
+
* canonical APK path) rather than macOS bundle identities.
|
|
1183
|
+
*/
|
|
1184
|
+
declare function assertAndroidAppAllowed(allowedApps: string[], app: string, resolvedPackage?: string): void;
|
|
592
1185
|
|
|
593
1186
|
type StepCallback = (result: StepResult, step: Step, index: number) => void;
|
|
594
1187
|
|
|
@@ -606,6 +1199,10 @@ type RunOptions = {
|
|
|
606
1199
|
junit?: boolean;
|
|
607
1200
|
/** Inject a macOS helper client (tests / a prebuilt binary); defaults to spawning the helper. */
|
|
608
1201
|
macClientFactory?: () => MacHelperClient;
|
|
1202
|
+
/** Inject an Android session factory (tests); defaults to {@link launchAndroidSession}. */
|
|
1203
|
+
androidSessionFactory?: (options: LaunchAndroidOptions) => Promise<AndroidSession>;
|
|
1204
|
+
/** Inject an iOS session factory (tests); defaults to {@link launchIosSession}. */
|
|
1205
|
+
iosSessionFactory?: (options: LaunchIosOptions) => Promise<IosSession>;
|
|
609
1206
|
};
|
|
610
1207
|
declare function runHunt(options: RunOptions): Promise<{
|
|
611
1208
|
result: RunResult;
|
|
@@ -813,6 +1410,36 @@ declare const configSchema: z.ZodObject<{
|
|
|
813
1410
|
}, {
|
|
814
1411
|
app: string;
|
|
815
1412
|
type: "macos";
|
|
1413
|
+
}>, z.ZodObject<{
|
|
1414
|
+
type: z.ZodLiteral<"android">;
|
|
1415
|
+
app: z.ZodString;
|
|
1416
|
+
deviceSerial: z.ZodOptional<z.ZodString>;
|
|
1417
|
+
coldStart: z.ZodOptional<z.ZodBoolean>;
|
|
1418
|
+
}, "strict", z.ZodTypeAny, {
|
|
1419
|
+
app: string;
|
|
1420
|
+
type: "android";
|
|
1421
|
+
deviceSerial?: string | undefined;
|
|
1422
|
+
coldStart?: boolean | undefined;
|
|
1423
|
+
}, {
|
|
1424
|
+
app: string;
|
|
1425
|
+
type: "android";
|
|
1426
|
+
deviceSerial?: string | undefined;
|
|
1427
|
+
coldStart?: boolean | undefined;
|
|
1428
|
+
}>, z.ZodObject<{
|
|
1429
|
+
type: z.ZodLiteral<"ios">;
|
|
1430
|
+
app: z.ZodString;
|
|
1431
|
+
udid: z.ZodOptional<z.ZodString>;
|
|
1432
|
+
coldStart: z.ZodOptional<z.ZodBoolean>;
|
|
1433
|
+
}, "strict", z.ZodTypeAny, {
|
|
1434
|
+
app: string;
|
|
1435
|
+
type: "ios";
|
|
1436
|
+
udid?: string | undefined;
|
|
1437
|
+
coldStart?: boolean | undefined;
|
|
1438
|
+
}, {
|
|
1439
|
+
app: string;
|
|
1440
|
+
type: "ios";
|
|
1441
|
+
udid?: string | undefined;
|
|
1442
|
+
coldStart?: boolean | undefined;
|
|
816
1443
|
}>, z.ZodObject<{
|
|
817
1444
|
type: z.ZodOptional<z.ZodLiteral<"web">>;
|
|
818
1445
|
url: z.ZodString;
|
|
@@ -959,6 +1586,16 @@ declare const configSchema: z.ZodObject<{
|
|
|
959
1586
|
} | {
|
|
960
1587
|
app: string;
|
|
961
1588
|
type: "macos";
|
|
1589
|
+
} | {
|
|
1590
|
+
app: string;
|
|
1591
|
+
type: "android";
|
|
1592
|
+
deviceSerial?: string | undefined;
|
|
1593
|
+
coldStart?: boolean | undefined;
|
|
1594
|
+
} | {
|
|
1595
|
+
app: string;
|
|
1596
|
+
type: "ios";
|
|
1597
|
+
udid?: string | undefined;
|
|
1598
|
+
coldStart?: boolean | undefined;
|
|
962
1599
|
};
|
|
963
1600
|
browser?: {
|
|
964
1601
|
timeout?: number | undefined;
|
|
@@ -1014,6 +1651,16 @@ declare const configSchema: z.ZodObject<{
|
|
|
1014
1651
|
} | {
|
|
1015
1652
|
app: string;
|
|
1016
1653
|
type: "macos";
|
|
1654
|
+
} | {
|
|
1655
|
+
app: string;
|
|
1656
|
+
type: "android";
|
|
1657
|
+
deviceSerial?: string | undefined;
|
|
1658
|
+
coldStart?: boolean | undefined;
|
|
1659
|
+
} | {
|
|
1660
|
+
app: string;
|
|
1661
|
+
type: "ios";
|
|
1662
|
+
udid?: string | undefined;
|
|
1663
|
+
coldStart?: boolean | undefined;
|
|
1017
1664
|
};
|
|
1018
1665
|
browser?: {
|
|
1019
1666
|
timeout?: number | undefined;
|
|
@@ -1212,6 +1859,97 @@ type AnalysisResult = {
|
|
|
1212
1859
|
};
|
|
1213
1860
|
declare function analyzePage(page: DomEvaluator): Promise<AnalysisResult>;
|
|
1214
1861
|
|
|
1862
|
+
/**
|
|
1863
|
+
* PROWL-055 / ARCH-007 — macOS analyzer.
|
|
1864
|
+
*
|
|
1865
|
+
* The native analog of {@link analyzePage}: dumps a macOS app's interactive
|
|
1866
|
+
* elements with ranked selector candidates so hunt authors don't have to guess
|
|
1867
|
+
* accessibility identifiers. It talks to the same `prowl-macdriver` helper the
|
|
1868
|
+
* runner uses ({@link MacHelperClient}) — reading the AX tree, the window list,
|
|
1869
|
+
* and (read-only) the status-item menu — and shapes the result to mirror the web
|
|
1870
|
+
* analyzer's feel.
|
|
1871
|
+
*
|
|
1872
|
+
* Selector ranking (best → last resort), matching the driver's selector dialect
|
|
1873
|
+
* so the emitted selectors are directly usable in hunts:
|
|
1874
|
+
* id=<AXIdentifier> (best — the native `data-testid`)
|
|
1875
|
+
* label="<exact title/desc>" (exact accessibility label)
|
|
1876
|
+
* role=<role>[name="<name>"] (role + accessible name)
|
|
1877
|
+
* text="<substring>" (last resort — substring match)
|
|
1878
|
+
*
|
|
1879
|
+
* Read-only: the ONLY state-changing interaction is opening the status-item menu
|
|
1880
|
+
* to read its items (their identifiers are gold) and immediately closing it.
|
|
1881
|
+
*/
|
|
1882
|
+
|
|
1883
|
+
/**
|
|
1884
|
+
* The interactive AX roles the analyzer surfaces from the window tree. Menu
|
|
1885
|
+
* items are collected separately via the status-item menu; windows are listed
|
|
1886
|
+
* as navigable surfaces. Tuned from the roles the helper's `tree`/`openMenu`
|
|
1887
|
+
* payloads actually expose for controls.
|
|
1888
|
+
*/
|
|
1889
|
+
declare const INTERACTIVE_ROLES: ReadonlySet<string>;
|
|
1890
|
+
/** Default AX-tree depth requested from the helper (deeper than the run default). */
|
|
1891
|
+
declare const DEFAULT_ANALYZE_TREE_DEPTH = 20;
|
|
1892
|
+
/** A single element the `axInfo` snapshot describes (tree / menu / window node). */
|
|
1893
|
+
type MacAxNode = {
|
|
1894
|
+
role?: string;
|
|
1895
|
+
title?: string;
|
|
1896
|
+
description?: string;
|
|
1897
|
+
value?: string;
|
|
1898
|
+
identifier?: string;
|
|
1899
|
+
enabled?: boolean;
|
|
1900
|
+
children?: MacAxNode[];
|
|
1901
|
+
};
|
|
1902
|
+
/** An interactive element with ranked selector candidates (best first). */
|
|
1903
|
+
type MacAnalysisElement = {
|
|
1904
|
+
role: string;
|
|
1905
|
+
title?: string;
|
|
1906
|
+
description?: string;
|
|
1907
|
+
value?: string;
|
|
1908
|
+
identifier?: string;
|
|
1909
|
+
enabled?: boolean;
|
|
1910
|
+
/** Where the element was discovered: the app's window tree or the status menu. */
|
|
1911
|
+
source: "window" | "menu";
|
|
1912
|
+
/** Ranked selector candidates, best first. Always at least one entry. */
|
|
1913
|
+
selectors: string[];
|
|
1914
|
+
};
|
|
1915
|
+
/** A top-level window, exposed as a navigable surface with its best selector. */
|
|
1916
|
+
type MacAnalysisWindow = {
|
|
1917
|
+
title?: string;
|
|
1918
|
+
identifier?: string;
|
|
1919
|
+
/** Best selector candidate for the window. */
|
|
1920
|
+
selector: string;
|
|
1921
|
+
};
|
|
1922
|
+
type MacAnalysisResult = {
|
|
1923
|
+
/** Bundle id (or the app reference) of the analyzed app. */
|
|
1924
|
+
app: string;
|
|
1925
|
+
elements: MacAnalysisElement[];
|
|
1926
|
+
windows: MacAnalysisWindow[];
|
|
1927
|
+
menuItems: MacAnalysisElement[];
|
|
1928
|
+
};
|
|
1929
|
+
/**
|
|
1930
|
+
* Ranked selector candidates for an element, best first. Mirrors the driver's
|
|
1931
|
+
* selector dialect (`id=` > `label=` > `role=…[name="…"]` > `text=`). Falls back
|
|
1932
|
+
* to a bare `role=<role>` so every element with a role is at least addressable.
|
|
1933
|
+
*/
|
|
1934
|
+
declare function rankMacSelectors(node: MacAxNode): string[];
|
|
1935
|
+
type AnalyzeMacOptions = {
|
|
1936
|
+
/** Bundle id / app label to report in the result. */
|
|
1937
|
+
app: string;
|
|
1938
|
+
/** AX-tree depth to request from the helper. */
|
|
1939
|
+
treeDepth?: number;
|
|
1940
|
+
/** Timeout (seconds) for opening the status-item menu. */
|
|
1941
|
+
menuTimeoutSeconds?: number;
|
|
1942
|
+
};
|
|
1943
|
+
/**
|
|
1944
|
+
* Analyze an already-launched macOS app through `client`, returning its
|
|
1945
|
+
* interactive elements, windows, and status-menu items with ranked selectors.
|
|
1946
|
+
*
|
|
1947
|
+
* The caller owns the session lifecycle (launch + guardrails + teardown); this
|
|
1948
|
+
* function is read-only apart from opening and immediately closing the
|
|
1949
|
+
* status-item menu to read its contents.
|
|
1950
|
+
*/
|
|
1951
|
+
declare function analyzeMacApp(client: MacHelperClient, options: AnalyzeMacOptions): Promise<MacAnalysisResult>;
|
|
1952
|
+
|
|
1215
1953
|
type AiProvider = "anthropic" | "openai";
|
|
1216
1954
|
type AiConfig = {
|
|
1217
1955
|
provider: AiProvider;
|
|
@@ -1229,4 +1967,4 @@ type GenerateOptions = {
|
|
|
1229
1967
|
};
|
|
1230
1968
|
declare function generateHunt(options: GenerateOptions): Promise<string>;
|
|
1231
1969
|
|
|
1232
|
-
export { type AnalysisResult, type AssertScreenshotStep, type Assertion, type AssertionResult, type BrowserChannel, type BrowserEngine, type BugFailure, type BugLogSummary, type CiFailureCluster, type CiFlakyHunt, type CiHuntResult, type CiResult, type CiStatus, type Config, DEFAULT_FLAKY_THRESHOLD, DEFAULT_REQUEST_TIMEOUT_MS, type EvalScriptStep, type FailureCluster, type FlakyScore, type GenerateOptions, type HealResult, type HistoryEntry, type HistoryFile, type Hunt, type IfStep, type LaunchMacOptions, type MacDriverOptions, type MacHelperClient, type MacQuery, type MacSession, type MacosTarget, type MockRouteStep, type PageElement, type PageForm, type PageLink, type RankFlakyOptions, type ReliabilityConfig, type RepeatStep, type RunArtifacts, type RunOptions, type RunResult, type RunScriptStep, type RunSuiteHooks, type RunSuiteOptions, type RunSuiteResult, SpawnMacHelperClient, type SpawnMacHelperOptions, type Step, type StepResult, type Target, type UnmockRouteStep, type UpdateBacklogOptions, type Viewport, WEB_ONLY_STEP_TYPES, type WebTarget, analyzePage, assertStepsSupportedByTarget, assertTargetAppAllowed, buildHealCandidates, closeMacSession, clusterFailures, computeFlakeScore, configSchema, createMacDriver, extractFailures, extractSelectorIntent, generateHunt, healSelector, huntSchema, interpolateHunt, launchMacSession, listHunts, loadConfig, loadHunt, loadHuntMeta, loadHuntTags, macdriverBuildInstructions, parseMacSelector, rankFlaky, readHistory, readHuntHistory, resolveHelperBinary, runHunt, runSuite, stepSchema, updateBacklogFromSuite, webOnlyReason };
|
|
1970
|
+
export { ANDROID_KEYCODES, type AdbDevice, type AdbResult, type AdbRunner, type AdbSpawner, type AgentApks, type AgentConnector, type AnalysisResult, type AnalyzeMacOptions, type AndroidAgentClient, type AndroidDriverOptions, type AndroidLocator, type AndroidQuery, type AndroidSession, type AndroidTarget, type AssertScreenshotStep, type Assertion, type AssertionResult, type BrowserChannel, type BrowserEngine, type BugFailure, type BugLogSummary, type CiFailureCluster, type CiFlakyHunt, type CiHuntResult, type CiResult, type CiStatus, type Config, DEFAULT_AGENT_REQUEST_TIMEOUT_MS, DEFAULT_ANALYZE_TREE_DEPTH, DEFAULT_FLAKY_THRESHOLD, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_SIMULATOR_LOCK_ROOT, DEFAULT_WDA_REQUEST_TIMEOUT_MS, type EvalScriptStep, type FailureCluster, type FetchLike$1 as FetchLike, type FlakyScore, type GenerateOptions, type HealResult, type HistoryEntry, type HistoryFile, type Hunt, INTERACTIVE_ROLES, IOS_PRESS_KEYS, type IfStep, type IosAgentClient, type IosAgentConnector, type IosDriverOptions, type IosLocator, type IosQuery, type IosSession, type IosTarget, type LaunchAndroidOptions, type LaunchIosOptions, type LaunchMacOptions, type MacAnalysisElement, type MacAnalysisResult, type MacAnalysisWindow, type MacAxNode, type MacDriverOptions, type MacHelperClient, type MacQuery, type MacSession, type MacosTarget, type MockRouteStep, type PageElement, type PageForm, type PageLink, type RankFlakyOptions, type ReliabilityConfig, type RepeatStep, type ReserveSimulatorOptions, type ResolveWdaRunnerOptions, type RunArtifacts, type RunOptions, type RunResult, type RunScriptStep, type RunSuiteHooks, type RunSuiteOptions, type RunSuiteResult, type SimDevice, type SimctlResult, type SimctlRunner, type SimulatorReservation, SpawnMacHelperClient, type SpawnMacHelperOptions, type Step, type StepResult, type Target, UIA2_REMOTE_PORT, Uia2HttpError, Uia2Transport, type Uia2TransportOptions, type UnmockRouteStep, type UpdateBacklogOptions, type Viewport, WDA_RUNNER_APP_NAME, WDA_RUNNER_BUNDLE_ID, WEB_ONLY_STEP_TYPES, WdaHttpError, WdaTransport, type WdaTransportOptions, type WebTarget, analyzeMacApp, analyzePage, androidAppAllowedIdentities, androidQueryToLocator, assertAndroidAppAllowed, assertIosAppAllowed, assertStepsSupportedByTarget, assertTargetAppAllowed, bootedDevices, bootedSimulators, buildHealCandidates, closeAndroidSession, closeIosSession, closeMacSession, clusterFailures, computeFlakeScore, configSchema, createAndroidDriver, createIosDriver, createMacDriver, createUia2AgentClient, createUia2Session, createWdaAgentClient, createWdaSession, defaultAgentConnector, defaultIosAgentConnector, escapePredicateArg, escapeUiSelectorArg, extractElementId, extractFailures, extractSelectorIntent, findFreePort, generateHunt, healSelector, huntSchema, interpolateHunt, iosAppAllowedIdentities, iosQueryToLocator, launchAndroidSession, launchIosSession, launchMacSession, listDevices, listHunts, listSimulators, loadConfig, loadHunt, loadHuntMeta, loadHuntTags, macdriverBuildInstructions, normalizeXcuiClassName, parseAaptPackage, parseAdbDevices, parseAndroidSelector, parseForwardPort, parseIosSelector, parseMacSelector, parseSimctlDevices, parseXcodeVersion, rankFlaky, rankMacSelectors, readHistory, readHuntHistory, readIosBundleIdentifier, reserveSimulatorUdid, resolveAgentApks, resolveHelperBinary, resolveWdaProject, resolveWdaRunner, runHunt, runSuite, selectDeviceSerial, selectSimulatorUdid, stepSchema, unwrapAndroidTextSelector, unwrapIosTextSelector, updateBacklogFromSuite, waitForAgentReady, waitForWdaReady, wdaCacheDir, webOnlyReason };
|