omowright 0.1.0 → 0.3.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.
Files changed (165) hide show
  1. package/README.md +33 -23
  2. package/TOOLS.md +140 -19
  3. package/dist/agent-tabs.d.ts +56 -0
  4. package/dist/aria-hidden.d.ts +1 -0
  5. package/dist/aside/cli-binary.d.ts +7 -0
  6. package/dist/aside/cli-contract.d.ts +9 -0
  7. package/dist/aside/errors.d.ts +8 -0
  8. package/dist/aside/line-transport.d.ts +11 -0
  9. package/dist/aside/mcp-transport.d.ts +11 -0
  10. package/dist/aside/onboard.d.ts +76 -0
  11. package/dist/aside/session-types.d.ts +68 -0
  12. package/dist/aside/session.d.ts +20 -0
  13. package/{bin/omowright-cloak.mjs → dist/bin/omowright-cloak.js} +28 -31
  14. package/dist/bridge-schemas.d.ts +326 -0
  15. package/dist/bridge-transport.d.ts +144 -0
  16. package/dist/browser-context.d.ts +4024 -0
  17. package/dist/browser-process.d.ts +10 -0
  18. package/dist/bsk/browser-signals.d.ts +23 -0
  19. package/dist/bsk/browsers.d.ts +46 -0
  20. package/dist/bsk/connect.d.ts +23 -0
  21. package/dist/bsk/daemon-info.d.ts +16 -0
  22. package/dist/bsk/external-extension.d.ts +74 -0
  23. package/dist/bsk/identify-browser.d.ts +48 -0
  24. package/dist/bsk/install-cli.d.ts +37 -0
  25. package/dist/bsk/ipc-client.d.ts +45 -0
  26. package/dist/bsk/onboard.d.ts +96 -0
  27. package/dist/bsk/reply-fields.d.ts +3 -0
  28. package/dist/bsk/screenshot.d.ts +24 -0
  29. package/dist/bsk/session.d.ts +142 -0
  30. package/dist/bsk/snapshot.d.ts +16 -0
  31. package/dist/bsk/targets.d.ts +20 -0
  32. package/dist/captcha-wait.d.ts +17 -0
  33. package/dist/captcha.d.ts +46 -0
  34. package/dist/cdp-errors.d.ts +38 -0
  35. package/dist/cdp-methods.d.ts +10 -0
  36. package/dist/cdp-protocol.d.ts +459 -0
  37. package/dist/chrome-profile.d.ts +77 -0
  38. package/dist/chrome.d.ts +130 -0
  39. package/dist/cloak-profile.d.ts +43 -0
  40. package/dist/connection.d.ts +4024 -0
  41. package/dist/console-events.d.ts +22 -0
  42. package/dist/cookies.d.ts +42 -0
  43. package/dist/core.d.ts +10810 -0
  44. package/dist/cua.d.ts +56 -0
  45. package/dist/dialog-policy.d.ts +43 -0
  46. package/dist/ego/bindings.d.ts +68 -0
  47. package/dist/ego/cdp-client.d.ts +28 -0
  48. package/dist/ego/client.d.ts +8 -0
  49. package/dist/ego/errors.d.ts +7 -0
  50. package/dist/emulate.d.ts +62 -0
  51. package/dist/engines.d.ts +59 -0
  52. package/dist/events.d.ts +93 -0
  53. package/dist/frames-snapshot.d.ts +58 -0
  54. package/dist/har.d.ts +88 -0
  55. package/dist/human-handoff.d.ts +30 -0
  56. package/{src/index.js → dist/index.d.ts} +12 -53
  57. package/dist/index.js +39262 -0
  58. package/dist/injected.d.ts +1 -0
  59. package/dist/instance-lock.d.ts +5 -0
  60. package/dist/instances.d.ts +45 -0
  61. package/dist/internal-capability.d.ts +1 -0
  62. package/dist/launch-endpoint.d.ts +34 -0
  63. package/dist/layers.d.ts +31 -0
  64. package/dist/llm.d.ts +1349 -0
  65. package/dist/lock-backend-win32-xbcm60vz.js +57 -0
  66. package/dist/lock-backend-win32.d.ts +3 -0
  67. package/dist/lock-backend.d.ts +6 -0
  68. package/dist/native-host-win32.d.ts +38 -0
  69. package/dist/network-events.d.ts +66 -0
  70. package/dist/network-snoop.d.ts +56 -0
  71. package/dist/nul-frames.d.ts +4 -0
  72. package/dist/open-shadow-query.d.ts +1 -0
  73. package/dist/owner-only.d.ts +15 -0
  74. package/dist/page-bundle.js +1587 -0
  75. package/dist/page-events.d.ts +25 -0
  76. package/dist/page-routes.d.ts +30 -0
  77. package/dist/page-setup.d.ts +55 -0
  78. package/dist/pipe.d.ts +71 -0
  79. package/dist/process-start-time.d.ts +2 -0
  80. package/dist/read-property.d.ts +2 -0
  81. package/dist/routes.d.ts +60 -0
  82. package/dist/running-browser.d.ts +39 -0
  83. package/dist/scroll-collect.d.ts +36 -0
  84. package/dist/serial-emitter.d.ts +5 -0
  85. package/dist/shared-connections.d.ts +11 -0
  86. package/dist/snapshot-diff.d.ts +57 -0
  87. package/dist/text-matching.d.ts +21 -0
  88. package/dist/trace.d.ts +59 -0
  89. package/dist/url-match.d.ts +7 -0
  90. package/dist/viewport.d.ts +26 -0
  91. package/dist/ws.d.ts +62 -0
  92. package/package.json +47 -26
  93. package/presets/agent-events/SKILL.md +1 -1
  94. package/presets/captcha/SKILL.md +1 -3
  95. package/presets/chrome/SKILL.md +11 -7
  96. package/presets/cloak-bridge/SKILL.md +11 -11
  97. package/presets/network/SKILL.md +15 -13
  98. package/presets/visual-browse/SKILL.md +14 -10
  99. package/skills/omowright/SKILL.md +77 -47
  100. package/skills/omowright/references/aside.md +50 -0
  101. package/skills/omowright/references/browserskill.md +39 -33
  102. package/skills/omowright/references/ego.md +24 -0
  103. package/skills/omowright/references/eval-kernel.md +44 -23
  104. package/skills/omowright/references/frames-layers-human.md +16 -7
  105. package/skills/omowright/references/quickstart.md +17 -4
  106. package/skills/omowright/references/stealth.md +7 -7
  107. package/src/agent-tabs.js +0 -160
  108. package/src/bridge-schemas.js +0 -44
  109. package/src/bridge-transport.js +0 -57
  110. package/src/browser-process.js +0 -122
  111. package/src/bsk/browser-signals.js +0 -90
  112. package/src/bsk/browsers.js +0 -114
  113. package/src/bsk/connect.js +0 -45
  114. package/src/bsk/daemon-info.js +0 -100
  115. package/src/bsk/external-extension.js +0 -110
  116. package/src/bsk/identify-browser.js +0 -88
  117. package/src/bsk/install-cli.js +0 -81
  118. package/src/bsk/ipc-client.js +0 -236
  119. package/src/bsk/onboard.js +0 -133
  120. package/src/bsk/screenshot.js +0 -49
  121. package/src/bsk/session.js +0 -131
  122. package/src/bsk/snapshot.js +0 -56
  123. package/src/bsk/targets.js +0 -25
  124. package/src/captcha-wait.js +0 -74
  125. package/src/captcha.js +0 -142
  126. package/src/cdp-errors.js +0 -23
  127. package/src/cdp-methods.js +0 -61
  128. package/src/chrome-profile.js +0 -176
  129. package/src/chrome.js +0 -192
  130. package/src/cloak-profile.js +0 -266
  131. package/src/connection.js +0 -135
  132. package/src/cookies.js +0 -29
  133. package/src/core.js +0 -1710
  134. package/src/cua.js +0 -74
  135. package/src/dialog-policy.js +0 -80
  136. package/src/emulate.js +0 -127
  137. package/src/events.js +0 -111
  138. package/src/frames-snapshot.js +0 -138
  139. package/src/har.js +0 -103
  140. package/src/human-handoff.js +0 -122
  141. package/src/injected.js +0 -3
  142. package/src/instance-lock.js +0 -230
  143. package/src/instances.js +0 -493
  144. package/src/internal-capability.js +0 -1
  145. package/src/launch-endpoint.js +0 -185
  146. package/src/layers.js +0 -138
  147. package/src/llm.js +0 -201
  148. package/src/lock-file.js +0 -130
  149. package/src/native-host-win32.js +0 -201
  150. package/src/network-events.js +0 -201
  151. package/src/network-snoop.js +0 -229
  152. package/src/open-shadow-query.js +0 -22
  153. package/src/owner-only.js +0 -109
  154. package/src/page-bundle.js +0 -1397
  155. package/src/page-routes.js +0 -94
  156. package/src/pipe.js +0 -391
  157. package/src/routes.js +0 -256
  158. package/src/running-browser.js +0 -85
  159. package/src/scroll-collect.js +0 -73
  160. package/src/serial-emitter.js +0 -17
  161. package/src/shared-connections.js +0 -278
  162. package/src/snapshot-diff.js +0 -75
  163. package/src/trace.js +0 -183
  164. package/src/url-match.js +0 -148
  165. package/src/viewport.js +0 -12
@@ -0,0 +1,25 @@
1
+ import type { CdpEventMeta, CdpExceptionDetails, CdpUnsubscribe } from "./cdp-protocol.js";
2
+ export declare const PAGE_EVENT_NAMES: readonly ["close", "console", "crash", "dialog", "domcontentloaded", "download", "filechooser", "frameattached", "framedetached", "framenavigated", "load", "pageerror", "popup", "request", "response"];
3
+ export type PageEventName = (typeof PAGE_EVENT_NAMES)[number];
4
+ /** Runtime.exceptionThrown as Chromium sends it (the field this module reads). */
5
+ export interface ExceptionThrownEvent {
6
+ exceptionDetails?: Partial<CdpExceptionDetails>;
7
+ }
8
+ export interface PageErrorsPage {
9
+ cdp: {
10
+ on(event: "Runtime.exceptionThrown", handler: (event: ExceptionThrownEvent, meta: CdpEventMeta | undefined) => unknown): CdpUnsubscribe;
11
+ };
12
+ frameManager: {
13
+ hasSession(sessionId: string): boolean;
14
+ frames: ReadonlyMap<string, {
15
+ sessionId: string;
16
+ isolatedContextId?: number | undefined;
17
+ }>;
18
+ };
19
+ events: {
20
+ emit(name: "pageerror", payload: Error): Promise<unknown>;
21
+ };
22
+ }
23
+ export declare const RUNTIME_PAGE_EVENTS: ReadonlySet<string>;
24
+ export declare function assertPageEvent(name: unknown): asserts name is PageEventName;
25
+ export declare function subscribePageErrors(page: PageErrorsPage): CdpUnsubscribe;
@@ -0,0 +1,30 @@
1
+ import type { RouteContinueOverrides, RouteFulfillOptions, RoutesPage } from "./routes.js";
2
+ /** Playwright-style request view handed to a page.route() handler. */
3
+ export interface PageRouteRequest {
4
+ url(): string;
5
+ method(): string;
6
+ headers(): Record<string, string>;
7
+ postData(): string | null;
8
+ resourceType(): string;
9
+ }
10
+ export interface PageRouteFulfillOptions extends RouteFulfillOptions {
11
+ json?: unknown;
12
+ path?: string | undefined;
13
+ }
14
+ export interface PageRoute {
15
+ request(): PageRouteRequest;
16
+ continue(overrides?: RouteContinueOverrides): Promise<unknown>;
17
+ fallback(): Promise<void>;
18
+ abort(errorCode?: string): Promise<unknown>;
19
+ fulfill(options?: PageRouteFulfillOptions): Promise<unknown>;
20
+ }
21
+ export type PageRouteHandler = (route: PageRoute, request: PageRouteRequest) => unknown;
22
+ export type PageRouteUrlPredicate = (url: URL) => unknown;
23
+ /** A glob (`*`, `**`, `{a,b}`), a RegExp, or a predicate over the parsed URL. */
24
+ export type PageRouteUrl = string | RegExp | PageRouteUrlPredicate;
25
+ export interface PageRouteOptions {
26
+ times?: number | undefined;
27
+ }
28
+ export declare function pageRoute(page: RoutesPage, match: PageRouteUrl, handler: PageRouteHandler, options?: PageRouteOptions): Promise<void>;
29
+ export declare function pageUnroute(page: RoutesPage, match: PageRouteUrl, handler?: PageRouteHandler): Promise<void>;
30
+ export declare function pageUnrouteAll(page: RoutesPage): Promise<void>;
@@ -0,0 +1,55 @@
1
+ import type { ViewportInput, ViewportSize } from "./viewport.js";
2
+ import type { CdpEventMeta, CdpEventPayload, CdpTransport, CdpUnsubscribe } from "./cdp-protocol.js";
3
+ /** The string-safe wire form bindingValue encodes a value into (JSON carries it both ways). */
4
+ export type EncodedBindingValue = ["undefined"] | ["number", string] | ["bigint", string] | ["array", EncodedBindingValue[]] | ["object", Array<[string, EncodedBindingValue]>] | ["value", unknown];
5
+ interface BindingCalledEvent {
6
+ name: string;
7
+ payload: string;
8
+ executionContextId: number;
9
+ }
10
+ /** The page surface init scripts, bindings, headers, viewport and media emulation need. */
11
+ export interface SetupPage {
12
+ cdp: Pick<CdpTransport, "send"> & {
13
+ on(event: "Runtime.bindingCalled", handler: (event: BindingCalledEvent, meta: CdpEventMeta) => unknown): CdpUnsubscribe;
14
+ on(event: "Target.detachedFromTarget", handler: (event: CdpEventPayload<"Target.detachedFromTarget">, meta: CdpEventMeta) => unknown): CdpUnsubscribe;
15
+ };
16
+ frameManager: {
17
+ readonly frames: ReadonlyMap<string, {
18
+ sessionId: string;
19
+ }>;
20
+ mainWorldContexts?: ReadonlyMap<string, string | undefined>;
21
+ sessionSetup?: (sessionId: string) => unknown;
22
+ };
23
+ events: {
24
+ on(name: "close", listener: () => unknown): unknown;
25
+ };
26
+ /** The page host; a host with setViewportSize repins through its agent-tab manager. */
27
+ browser: object;
28
+ /** Set by BrowserConnection.attachPage; exposeBinding hands it to the callback. */
29
+ context?: (() => unknown) | undefined;
30
+ frames(): ReadonlyArray<{
31
+ frameId: string;
32
+ }>;
33
+ resolveSessionId(): Promise<string>;
34
+ setCachedViewportSize(size: ViewportSize): void;
35
+ }
36
+ /** A function (called with `arg` in the page), source text, or a file's contents. */
37
+ export type InitScriptInput = ((arg: never) => unknown) | string | {
38
+ content?: string | undefined;
39
+ path?: string | undefined;
40
+ };
41
+ type MediaFeatureKey = "colorScheme" | "reducedMotion" | "forcedColors" | "contrast";
42
+ export type EmulateMediaOptions = {
43
+ media?: string | null | undefined;
44
+ } & {
45
+ [K in MediaFeatureKey]?: string | null | undefined;
46
+ };
47
+ export declare function hasPageBindings(page: SetupPage): boolean;
48
+ export declare function addInitScript(this: SetupPage, script: InitScriptInput, arg?: unknown): Promise<void>;
49
+ export declare function exposeFunction(this: SetupPage, name: string, callback: (...args: never[]) => unknown): Promise<void>;
50
+ export declare function exposeBinding(this: SetupPage, name: string, callback: (...args: never[]) => unknown): Promise<void>;
51
+ /** Validated at runtime: anything but a plain object of string values throws a TypeError. */
52
+ export declare function setExtraHTTPHeaders(this: SetupPage, headers: Readonly<Record<string, unknown>>): Promise<void>;
53
+ export declare function setViewportSize(this: SetupPage, viewport: ViewportInput): Promise<void>;
54
+ export declare function emulateMedia(this: SetupPage, options?: EmulateMediaOptions): Promise<void>;
55
+ export {};
package/dist/pipe.d.ts ADDED
@@ -0,0 +1,71 @@
1
+ import type { ChildProcess, SpawnOptions } from "node:child_process";
2
+ import { BrowserConnection } from "./connection.js";
3
+ import { Dialog } from "./dialog-policy.js";
4
+ import type { DialogOpeningParams, DialogPolicy } from "./dialog-policy.js";
5
+ import type { CdpEventMeta, CdpEventPayload, CdpResult, CdpSendOptions, CdpTargetSummary, CdpTransport, CdpUnsubscribe } from "./cdp-protocol.js";
6
+ import { SerialEmitter as Emittery } from "./serial-emitter.js";
7
+ export { CdpCommandTimeoutError, CdpPipeClosedError, CdpSessionDetachedError, CdpSessionCrashedError, } from "./cdp-errors.js";
8
+ export interface PipeCdpClientOptions {
9
+ /** Required: the constructor throws a TypeError without it. */
10
+ browserPath?: string | undefined;
11
+ browserArgs?: readonly string[] | undefined;
12
+ /** Spawn options for the browser process; `stdio` is always owned by the client. */
13
+ spawnOptions?: Omit<SpawnOptions, "stdio"> | undefined;
14
+ commandTimeoutMs?: number | undefined;
15
+ readinessTimeoutMs?: number | undefined;
16
+ logId?: string | undefined;
17
+ dialogPolicy?: DialogPolicy | undefined;
18
+ }
19
+ export interface ConnectPipeOptions extends PipeCdpClientOptions {
20
+ storageRoot?: string | undefined;
21
+ }
22
+ export interface PipeEventMeta extends CdpEventMeta {
23
+ dialog?: Dialog;
24
+ }
25
+ /** Event params the transport itself reads; everything else passes through untouched. */
26
+ interface PipeWireParams extends DialogOpeningParams {
27
+ sessionId?: string;
28
+ targetInfo?: {
29
+ targetId?: string;
30
+ [key: string]: unknown;
31
+ };
32
+ [key: string]: unknown;
33
+ }
34
+ /**
35
+ * One NUL-delimited frame as Chromium writes it. JSON boundary: `id` and
36
+ * `method` are checked with typeof before use; the rest follows the CDP wire format.
37
+ */
38
+ export interface PipeWireMessage {
39
+ id?: unknown;
40
+ method?: unknown;
41
+ sessionId?: string;
42
+ params?: PipeWireParams;
43
+ result?: {
44
+ sessionId?: string;
45
+ [key: string]: unknown;
46
+ };
47
+ error?: {
48
+ message?: string;
49
+ code?: unknown;
50
+ data?: unknown;
51
+ };
52
+ }
53
+ export declare class PipeCdpClient implements CdpTransport {
54
+ #private;
55
+ transportEvents: Emittery<void>;
56
+ logId: string;
57
+ constructor({ browserPath, browserArgs, spawnOptions, commandTimeoutMs, readinessTimeoutMs, logId, dialogPolicy, }: PipeCdpClientOptions);
58
+ get isConnected(): boolean;
59
+ get isHeadless(): boolean;
60
+ get childProcess(): ChildProcess | undefined;
61
+ get dialogPolicy(): DialogPolicy;
62
+ setDialogPolicy(policy: DialogPolicy): void;
63
+ ensureConnected(): Promise<void>;
64
+ send<M extends string>(method: M, params?: object, sessionId?: string, opts?: CdpSendOptions): Promise<CdpResult<M>>;
65
+ on<E extends string>(method: E, fn: (payload: CdpEventPayload<E>, meta: PipeEventMeta) => unknown): CdpUnsubscribe;
66
+ discoverTargets(): Promise<CdpTargetSummary[]>;
67
+ closeSession(sessionId: string): void;
68
+ close(): Promise<void>;
69
+ _handleTransportMessage(msg: PipeWireMessage): Promise<void> | undefined;
70
+ }
71
+ export declare function connectPipe({ browserPath, browserArgs, spawnOptions, storageRoot, commandTimeoutMs, readinessTimeoutMs, logId, dialogPolicy, }?: ConnectPipeOptions): Promise<BrowserConnection>;
@@ -0,0 +1,2 @@
1
+ export declare function processStartTime(pid: number): Promise<string | null>;
2
+ export declare function ownProcessStartTime(): Promise<string | null>;
@@ -0,0 +1,2 @@
1
+ /** `value[key]` for a value of unknown shape: null/undefined raise a TypeError, primitives read through their wrapper. */
2
+ export declare function readProperty(value: unknown, key: PropertyKey): unknown;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Request interception via the CDP Fetch domain.
3
+ *
4
+ * Enabling Fetch changes request timing and blocking patterns that bot
5
+ * defenses can fingerprint. Keep interception off by default and scope
6
+ * patterns tightly.
7
+ */
8
+ import type { CdpTransport } from "./cdp-protocol.js";
9
+ /** What a route handler and a match predicate see of a paused request. */
10
+ export interface RouteRequest {
11
+ url: string;
12
+ method: string;
13
+ headers: Record<string, string>;
14
+ postData: string | undefined;
15
+ resourceType: string;
16
+ }
17
+ export type RouteMatchPredicate = (request: Pick<RouteRequest, "url" | "method" | "resourceType" | "headers">) => unknown;
18
+ /** A glob (`*`, `?`), a substring, a RegExp, or a predicate. */
19
+ export type RouteMatch = string | RegExp | RouteMatchPredicate;
20
+ /** Headers as a name/value list or a record; every name and value is stringified. */
21
+ export type RouteHeaders = Array<{
22
+ name: unknown;
23
+ value?: unknown;
24
+ }> | Record<string, unknown>;
25
+ export interface RouteContinueOverrides {
26
+ url?: string | undefined;
27
+ method?: string | undefined;
28
+ headers?: RouteHeaders | undefined;
29
+ postData?: unknown;
30
+ }
31
+ export interface RouteFulfillOptions {
32
+ status?: number | undefined;
33
+ headers?: RouteHeaders | undefined;
34
+ contentType?: unknown;
35
+ body?: unknown;
36
+ }
37
+ export interface Route {
38
+ request: RouteRequest;
39
+ continue(overrides?: RouteContinueOverrides): Promise<unknown>;
40
+ fulfill(options?: RouteFulfillOptions): Promise<unknown>;
41
+ abort(errorReason?: string): Promise<unknown>;
42
+ fallback(): Promise<void>;
43
+ }
44
+ export type RouteHandler = (route: Route) => unknown;
45
+ export interface RouteOptions {
46
+ times?: number | undefined;
47
+ prepend?: boolean | undefined;
48
+ }
49
+ export interface RoutesController {
50
+ route(match: RouteMatch, handler: RouteHandler, options?: RouteOptions): Promise<void>;
51
+ unroute(match?: RouteMatch, handler?: RouteHandler): Promise<void>;
52
+ dispose(): Promise<void>;
53
+ readonly enabled: boolean;
54
+ }
55
+ /** The page surface routes need: its CDP transport and its session id. */
56
+ export interface RoutesPage {
57
+ cdp: Pick<CdpTransport, "send" | "on">;
58
+ resolveSessionId(): Promise<string>;
59
+ }
60
+ export declare function createRoutes(page: RoutesPage): RoutesController;
@@ -0,0 +1,39 @@
1
+ import type { ConnectOptions } from "./connection.js";
2
+ /** A profile to look in: a catalog row, or one built from a caller's userDataDirs entry. */
3
+ export interface RunningBrowserCandidate {
4
+ id: string;
5
+ label: string;
6
+ userDataDir: string;
7
+ }
8
+ export interface RunningBrowser extends RunningBrowserCandidate {
9
+ port: number;
10
+ wsUrl: string;
11
+ }
12
+ export interface FindRunningBrowserOptions {
13
+ /** A catalog id; ignored when userDataDirs is given. */
14
+ browser?: string | undefined;
15
+ /** Profiles to check instead of the browser catalog. */
16
+ userDataDirs?: readonly string[] | undefined;
17
+ portCheckMs?: number | undefined;
18
+ catalog?: (() => ReadonlyArray<RunningBrowserCandidate & {
19
+ hasProfile?: boolean;
20
+ }>) | undefined;
21
+ }
22
+ export interface ConnectRunningBrowserOptions extends FindRunningBrowserOptions {
23
+ connect?: ConnectOptions | undefined;
24
+ }
25
+ export interface DevToolsActivePort {
26
+ port: number;
27
+ wsPath: string | null;
28
+ }
29
+ export declare class RunningBrowserError extends Error {
30
+ code: string;
31
+ candidates: readonly RunningBrowser[];
32
+ constructor(code: string, message: string, candidates?: readonly RunningBrowser[]);
33
+ }
34
+ export declare function readDevToolsActivePort(userDataDir: string): Promise<DevToolsActivePort | null>;
35
+ export declare function findRunningBrowser({ browser, userDataDirs, portCheckMs, catalog, }?: FindRunningBrowserOptions): Promise<RunningBrowser>;
36
+ export declare function connectRunningBrowser(options?: ConnectRunningBrowserOptions): Promise<{
37
+ browser: import("./connection.js").BrowserConnection;
38
+ found: RunningBrowser;
39
+ }>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Scroll-driven collection over a network snoop (see ./network-snoop.ts).
3
+ */
4
+ export interface ScrollPage {
5
+ viewportSize(): {
6
+ width: number;
7
+ height: number;
8
+ } | null | undefined;
9
+ evaluate<T>(pageFunction: () => T): Promise<T>;
10
+ mouse: {
11
+ move(x: number, y: number): Promise<unknown>;
12
+ wheel(deltaX: number, deltaY: number): Promise<unknown>;
13
+ };
14
+ }
15
+ export interface JsonSnoop {
16
+ popJson(): Iterable<unknown>;
17
+ }
18
+ export type ScrollMode = "wheel" | "end";
19
+ export interface CollectWhileScrollingOptions {
20
+ minItems?: number;
21
+ maxScrolls?: number;
22
+ extract?: (json: unknown) => Iterable<unknown>;
23
+ scroll?: ScrollMode;
24
+ settleMs?: number;
25
+ }
26
+ export interface CollectWhileScrollingResult {
27
+ rounds: number;
28
+ total: number;
29
+ stoppedBecause: "minItems" | "maxScrolls" | "noGrowth";
30
+ }
31
+ /**
32
+ * Scrolls a page while draining JSON responses out of a snoop.
33
+ *
34
+ * Yields every extracted item and returns { rounds, total, stoppedBecause } when it stops.
35
+ */
36
+ export declare function collectWhileScrolling(page: ScrollPage, snoop: JsonSnoop, options?: CollectWhileScrollingOptions): AsyncGenerator<unknown, CollectWhileScrollingResult, undefined>;
@@ -0,0 +1,5 @@
1
+ export declare class SerialEmitter<Data> {
2
+ #private;
3
+ on(event: string, fn: (data: Data) => unknown): () => void;
4
+ emit(event: string, data: Data): Promise<void>;
5
+ }
@@ -0,0 +1,11 @@
1
+ import type { BrowserConnection, ConnectOptions } from "./connection.js";
2
+ export interface SharedConnectionHooks {
3
+ open: (options: Readonly<ConnectOptions>) => Promise<BrowserConnection>;
4
+ timeoutMs?: number | undefined;
5
+ }
6
+ export declare class SharedConnectionError extends Error {
7
+ code: string;
8
+ constructor();
9
+ }
10
+ export declare function canShareConnection(options: ConnectOptions | undefined): boolean;
11
+ export declare function acquireSharedConnection(webSocketDebuggerUrl: string, options: ConnectOptions, { open, timeoutMs }: SharedConnectionHooks): Promise<BrowserConnection>;
@@ -0,0 +1,57 @@
1
+ export interface TreeNode {
2
+ ref: string;
3
+ tree: string;
4
+ }
5
+ /** The frame registry a snapshot diff keys its baseline on; core's PageFrameManager satisfies it. */
6
+ export interface SnapshotFrames {
7
+ readonly mainFrameId: string | null;
8
+ getFrame(frameId: string | null): {
9
+ readonly isolatedContextId?: number | null | undefined;
10
+ } | null | undefined;
11
+ collectDescendantFrames(frameId: string | null): ReadonlyArray<{
12
+ readonly frameId: string;
13
+ }>;
14
+ }
15
+ /** The snapshot() options this module reads; anything else is scope and only keys the baseline. */
16
+ export interface SnapshotQuery {
17
+ [option: string]: unknown;
18
+ diff?: unknown;
19
+ find?: unknown;
20
+ context?: unknown;
21
+ }
22
+ /** A SnapshotQuery that passed validateSnapshotOptions. */
23
+ export interface ValidSnapshotQuery extends SnapshotQuery {
24
+ find?: string | RegExp | undefined;
25
+ context?: number | undefined;
26
+ }
27
+ export interface SnapshotText<Ref> {
28
+ tree?: string | undefined;
29
+ refs?: Readonly<Record<string, Ref>> | null | undefined;
30
+ }
31
+ export declare function validateSnapshotOptions(options: SnapshotQuery): asserts options is ValidSnapshotQuery;
32
+ export declare function findSnapshotLines<Ref>(snapshot: SnapshotText<Ref>, find: string | RegExp, context?: number): {
33
+ tree: string;
34
+ refs: Record<string, Ref>;
35
+ find: {
36
+ query: string;
37
+ matches: number;
38
+ };
39
+ };
40
+ export declare function snapshotResult<Ref>(frameManager: SnapshotFrames, options: ValidSnapshotQuery, snapshot: SnapshotText<Ref> & {
41
+ tree: string;
42
+ }): (SnapshotText<Ref> & {
43
+ tree: string;
44
+ }) | {
45
+ diff: {
46
+ added: TreeNode[];
47
+ changed: TreeNode[];
48
+ removed: string[];
49
+ focused: string | null;
50
+ };
51
+ full: boolean;
52
+ } | {
53
+ full: boolean;
54
+ reason: string;
55
+ tree: string;
56
+ refs?: Readonly<Record<string, Ref>> | null | undefined;
57
+ };
@@ -0,0 +1,21 @@
1
+ export type TextMatcher = RegExp | {
2
+ exact: string;
3
+ } | {
4
+ contains: string;
5
+ };
6
+ interface MatchNode extends Node {
7
+ readonly shadowRoot?: ShadowRoot | null;
8
+ }
9
+ interface MatchElement extends Element {
10
+ readonly labels?: NodeListOf<HTMLLabelElement> | null;
11
+ }
12
+ export declare function createTextMatching(isHidden?: (element: Element) => boolean, getRole?: (element: Element) => string, includeHidden?: boolean): {
13
+ normalize: (value: unknown) => string;
14
+ matches: (value: string, matcher: TextMatcher) => boolean;
15
+ skipped: (node: Node) => boolean;
16
+ text: (node: MatchNode) => string;
17
+ matchesText: (node: MatchNode, matcher: TextMatcher) => boolean;
18
+ labels: (node: MatchElement) => string[];
19
+ accessibleName: (node: Element) => string;
20
+ };
21
+ export {};
@@ -0,0 +1,59 @@
1
+ import type { NetworkPage } from "./network-events.js";
2
+ import type { BrowserEventPayloads } from "./events.js";
3
+ type TraceDownloadEvent = "downloadStarted" | "downloadFinished";
4
+ /** What the trace reads from a page "dialog" event (the Dialog in dialog-policy.ts). */
5
+ export interface TraceDialog {
6
+ type(): string | undefined;
7
+ message(): string | undefined;
8
+ defaultValue(): string;
9
+ readonly url: string | undefined;
10
+ }
11
+ export interface TracePage extends NetworkPage {
12
+ on(event: "dialog", listener: (dialog: TraceDialog) => unknown): () => void;
13
+ screenshot(options: {
14
+ type: "png";
15
+ }): Promise<Buffer | Uint8Array>;
16
+ url(): string;
17
+ /** A PageConsole with logs(), or a method returning the buffered entries. */
18
+ console?: unknown;
19
+ }
20
+ export interface TraceOptions {
21
+ /** Required: createTrace throws a TypeError without it. */
22
+ dir?: string | undefined;
23
+ screenshots?: boolean | undefined;
24
+ network?: boolean | undefined;
25
+ console?: boolean | undefined;
26
+ maxBodyBytes?: number | undefined;
27
+ events?: {
28
+ on<N extends TraceDownloadEvent>(name: N, listener: (payload: BrowserEventPayloads[N]) => unknown): () => void;
29
+ } | undefined;
30
+ }
31
+ interface TraceRecord {
32
+ kind: string;
33
+ ts: number;
34
+ seq: number;
35
+ }
36
+ export interface TraceSummary {
37
+ steps: number;
38
+ events: number;
39
+ network: number;
40
+ startedAt: number;
41
+ endedAt: number;
42
+ url: string;
43
+ }
44
+ /**
45
+ * Records a flight recorder trace for one page: steps, screenshots, network, console,
46
+ * dialogs, navigations and downloads, flushed to `dir` as trace.jsonl, trace.har and
47
+ * summary.json when {@link stop} runs.
48
+ */
49
+ export declare function createTrace(page: TracePage, options?: TraceOptions): {
50
+ step: <T>(name: unknown, fn: () => T | Promise<T>) => Promise<T>;
51
+ mark: (name: unknown, data?: unknown) => {
52
+ kind: string;
53
+ name: string;
54
+ data: {} | null;
55
+ } & TraceRecord;
56
+ stop: () => Promise<TraceSummary>;
57
+ readonly dir: string;
58
+ };
59
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Playwright's URL match: a glob string, a RegExp, or a predicate receiving a URL object.
3
+ * An empty or missing match accepts every URL; an invalid glob throws.
4
+ */
5
+ /** A glob string, a RegExp, or a predicate over the parsed URL. */
6
+ export type UrlMatch = string | RegExp | ((url: URL) => unknown);
7
+ export declare function urlMatches(urlString: string, match?: UrlMatch): Promise<boolean>;
@@ -0,0 +1,26 @@
1
+ import type { CdpTransport } from "./cdp-protocol.js";
2
+ export interface ViewportSize {
3
+ width: number;
4
+ height: number;
5
+ }
6
+ /** A viewport as callers pass it; validateViewport checks both fields. */
7
+ export interface ViewportInput {
8
+ width?: unknown;
9
+ height?: unknown;
10
+ }
11
+ export interface ViewportPage {
12
+ cdp: Pick<CdpTransport, "send">;
13
+ resolveSessionId(): Promise<string>;
14
+ setCachedViewportSize(size: ViewportSize): void;
15
+ }
16
+ export interface RepinViewportOptions {
17
+ deviceScaleFactor?: number | undefined;
18
+ mobile?: boolean | undefined;
19
+ }
20
+ export declare const DEFAULT_AGENT_VIEWPORT: Readonly<ViewportSize>;
21
+ declare function validateViewport(viewport: ViewportInput | null | undefined): ViewportSize;
22
+ export declare function repinViewport(page: ViewportPage, viewport: ViewportInput | null | undefined, options?: RepinViewportOptions): Promise<{
23
+ width: number;
24
+ height: number;
25
+ }>;
26
+ export { validateViewport };
package/dist/ws.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ declare module "ws" {
2
+ import type { EventEmitter } from "node:events";
3
+ import type { IncomingMessage } from "node:http";
4
+ import type { Duplex } from "node:stream";
5
+
6
+ type WebSocketReadyState = 0 | 1 | 2 | 3;
7
+
8
+ interface WebSocketMessageEvent {
9
+ data: string | Buffer | ArrayBuffer;
10
+ type: string;
11
+ }
12
+
13
+ interface WebSocketCloseEvent {
14
+ code: number;
15
+ reason: string;
16
+ wasClean: boolean;
17
+ type: string;
18
+ }
19
+
20
+ interface WebSocketClientOptions {
21
+ headers?: Record<string, string>;
22
+ }
23
+
24
+ class WebSocket {
25
+ static readonly CONNECTING: 0;
26
+ static readonly OPEN: 1;
27
+ static readonly CLOSING: 2;
28
+ static readonly CLOSED: 3;
29
+ readonly readyState: WebSocketReadyState;
30
+ constructor(address: string | URL, options?: WebSocketClientOptions);
31
+ send(data: string | Buffer | ArrayBuffer | ArrayBufferView): void;
32
+ close(code?: number, reason?: string): void;
33
+ addEventListener(type: "open" | "error", listener: () => void, options?: { once?: boolean }): void;
34
+ addEventListener(
35
+ type: "message",
36
+ listener: (event: WebSocketMessageEvent) => void,
37
+ options?: { once?: boolean },
38
+ ): void;
39
+ addEventListener(type: "close", listener: (event: WebSocketCloseEvent) => void, options?: { once?: boolean }): void;
40
+ on(event: "open" | "close", listener: () => void): this;
41
+ on(event: "message", listener: (data: Buffer, isBinary: boolean) => void): this;
42
+ }
43
+
44
+ class WebSocketServer extends EventEmitter {
45
+ constructor(options: { noServer: true });
46
+ on(event: "connection", listener: (socket: WebSocket, request: IncomingMessage) => void): this;
47
+ on(event: string | symbol, listener: (...args: unknown[]) => void): this;
48
+ once(event: "connection", listener: (socket: WebSocket, request: IncomingMessage) => void): this;
49
+ once(event: string | symbol, listener: (...args: unknown[]) => void): this;
50
+ handleUpgrade(
51
+ request: IncomingMessage,
52
+ socket: Duplex,
53
+ head: Buffer,
54
+ callback: (client: WebSocket, request: IncomingMessage) => void,
55
+ ): void;
56
+ close(callback?: (error?: Error) => void): void;
57
+ }
58
+
59
+ export { WebSocket, WebSocketServer };
60
+ export type { WebSocketCloseEvent, WebSocketMessageEvent };
61
+ export default WebSocket;
62
+ }