omowright 0.2.0 → 0.3.1
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 +43 -29
- package/TOOLS.md +9 -8
- package/dist/agent-tabs.d.ts +56 -0
- package/dist/aria-hidden.d.ts +1 -0
- package/dist/aside/cli-binary.d.ts +7 -0
- package/dist/aside/cli-contract.d.ts +9 -0
- package/dist/aside/errors.d.ts +8 -0
- package/dist/aside/line-transport.d.ts +11 -0
- package/dist/aside/mcp-transport.d.ts +11 -0
- package/dist/aside/onboard.d.ts +76 -0
- package/dist/aside/session-types.d.ts +68 -0
- package/dist/aside/session.d.ts +20 -0
- package/{bin/omowright-cloak.mjs → dist/bin/omowright-cloak.js} +28 -31
- package/dist/bridge-schemas.d.ts +326 -0
- package/dist/bridge-transport.d.ts +144 -0
- package/dist/browser-context.d.ts +4024 -0
- package/dist/browser-process.d.ts +10 -0
- package/dist/bsk/browser-signals.d.ts +23 -0
- package/dist/bsk/browsers.d.ts +46 -0
- package/dist/bsk/connect.d.ts +23 -0
- package/dist/bsk/daemon-info.d.ts +16 -0
- package/dist/bsk/external-extension.d.ts +74 -0
- package/dist/bsk/identify-browser.d.ts +48 -0
- package/dist/bsk/install-cli.d.ts +37 -0
- package/dist/bsk/ipc-client.d.ts +45 -0
- package/dist/bsk/onboard.d.ts +96 -0
- package/dist/bsk/reply-fields.d.ts +3 -0
- package/dist/bsk/screenshot.d.ts +24 -0
- package/dist/bsk/session.d.ts +142 -0
- package/dist/bsk/snapshot.d.ts +16 -0
- package/dist/bsk/targets.d.ts +20 -0
- package/dist/captcha-wait.d.ts +17 -0
- package/dist/captcha.d.ts +46 -0
- package/dist/cdp-errors.d.ts +38 -0
- package/dist/cdp-methods.d.ts +10 -0
- package/dist/cdp-protocol.d.ts +459 -0
- package/dist/chrome-profile.d.ts +77 -0
- package/dist/chrome.d.ts +130 -0
- package/dist/cloak-profile.d.ts +43 -0
- package/dist/connection.d.ts +4024 -0
- package/dist/console-events.d.ts +22 -0
- package/dist/cookies.d.ts +42 -0
- package/dist/core.d.ts +10810 -0
- package/dist/cua.d.ts +56 -0
- package/dist/dialog-policy.d.ts +43 -0
- package/dist/ego/bindings.d.ts +68 -0
- package/dist/ego/cdp-client.d.ts +28 -0
- package/dist/ego/client.d.ts +8 -0
- package/dist/ego/errors.d.ts +7 -0
- package/dist/emulate.d.ts +62 -0
- package/dist/engines.d.ts +59 -0
- package/dist/events.d.ts +93 -0
- package/dist/frames-snapshot.d.ts +58 -0
- package/dist/har.d.ts +88 -0
- package/dist/human-handoff.d.ts +30 -0
- package/{src/index.js → dist/index.d.ts} +12 -55
- package/dist/index.js +39478 -0
- package/dist/injected.d.ts +1 -0
- package/dist/instance-lock.d.ts +5 -0
- package/dist/instances.d.ts +45 -0
- package/dist/internal-capability.d.ts +1 -0
- package/dist/launch-endpoint.d.ts +34 -0
- package/dist/layers.d.ts +31 -0
- package/dist/llm.d.ts +1349 -0
- package/dist/lock-backend-win32-xbcm60vz.js +57 -0
- package/dist/lock-backend-win32.d.ts +3 -0
- package/dist/lock-backend.d.ts +6 -0
- package/dist/native-host-win32.d.ts +38 -0
- package/dist/network-events.d.ts +66 -0
- package/dist/network-snoop.d.ts +56 -0
- package/dist/nul-frames.d.ts +4 -0
- package/dist/open-shadow-query.d.ts +1 -0
- package/dist/owner-only.d.ts +15 -0
- package/dist/page-bundle.js +1597 -0
- package/dist/page-events.d.ts +25 -0
- package/dist/page-routes.d.ts +30 -0
- package/dist/page-setup.d.ts +55 -0
- package/dist/pipe.d.ts +71 -0
- package/dist/process-start-time.d.ts +2 -0
- package/dist/read-property.d.ts +2 -0
- package/dist/routes.d.ts +60 -0
- package/dist/running-browser.d.ts +39 -0
- package/dist/scroll-collect.d.ts +36 -0
- package/dist/serial-emitter.d.ts +5 -0
- package/dist/shared-connections.d.ts +11 -0
- package/dist/snapshot-diff.d.ts +57 -0
- package/dist/text-matching.d.ts +21 -0
- package/dist/trace.d.ts +59 -0
- package/dist/url-match.d.ts +7 -0
- package/dist/viewport.d.ts +26 -0
- package/dist/ws.d.ts +62 -0
- package/package.json +47 -26
- package/presets/agent-events/SKILL.md +1 -1
- package/presets/captcha/SKILL.md +1 -3
- package/presets/chrome/SKILL.md +2 -2
- package/presets/cloak-bridge/SKILL.md +11 -11
- package/presets/network/SKILL.md +15 -13
- package/presets/visual-browse/SKILL.md +14 -10
- package/skills/omowright/SKILL.md +83 -49
- package/skills/omowright/references/aside.md +50 -0
- package/skills/omowright/references/browserskill.md +29 -32
- package/skills/omowright/references/ego.md +24 -0
- package/skills/omowright/references/eval-kernel.md +44 -23
- package/skills/omowright/references/frames-layers-human.md +16 -7
- package/skills/omowright/references/quickstart.md +7 -4
- package/skills/omowright/references/stealth.md +11 -8
- package/src/agent-tabs.js +0 -179
- package/src/aria-hidden.js +0 -47
- package/src/bridge-schemas.js +0 -44
- package/src/bridge-transport.js +0 -83
- package/src/browser-context.js +0 -105
- package/src/browser-process.js +0 -127
- package/src/bsk/browser-signals.js +0 -90
- package/src/bsk/browsers.js +0 -114
- package/src/bsk/connect.js +0 -75
- package/src/bsk/daemon-info.js +0 -100
- package/src/bsk/external-extension.js +0 -110
- package/src/bsk/identify-browser.js +0 -88
- package/src/bsk/install-cli.js +0 -81
- package/src/bsk/ipc-client.js +0 -236
- package/src/bsk/onboard.js +0 -140
- package/src/bsk/screenshot.js +0 -49
- package/src/bsk/session.js +0 -131
- package/src/bsk/snapshot.js +0 -56
- package/src/bsk/targets.js +0 -25
- package/src/captcha-wait.js +0 -79
- package/src/captcha.js +0 -142
- package/src/cdp-errors.js +0 -23
- package/src/cdp-methods.js +0 -69
- package/src/chrome-profile.js +0 -176
- package/src/chrome.js +0 -194
- package/src/cloak-profile.js +0 -266
- package/src/connection.js +0 -234
- package/src/console-events.js +0 -12
- package/src/cookies.js +0 -39
- package/src/core.js +0 -1702
- package/src/cua.js +0 -74
- package/src/dialog-policy.js +0 -80
- package/src/emulate.js +0 -127
- package/src/events.js +0 -111
- package/src/frames-snapshot.js +0 -138
- package/src/har.js +0 -103
- package/src/human-handoff.js +0 -124
- package/src/injected.js +0 -3
- package/src/instance-lock.js +0 -74
- package/src/instances.js +0 -490
- package/src/internal-capability.js +0 -1
- package/src/launch-endpoint.js +0 -185
- package/src/layers.js +0 -138
- package/src/llm.js +0 -201
- package/src/lock-backend-win32.js +0 -54
- package/src/lock-backend.js +0 -81
- package/src/native-host-win32.js +0 -201
- package/src/network-events.js +0 -223
- package/src/network-snoop.js +0 -229
- package/src/nul-frames.js +0 -28
- package/src/open-shadow-query.js +0 -101
- package/src/owner-only.js +0 -196
- package/src/page-bundle.js +0 -1478
- package/src/page-events.js +0 -45
- package/src/page-routes.js +0 -94
- package/src/page-setup.js +0 -239
- package/src/pipe.js +0 -418
- package/src/process-start-time.js +0 -64
- package/src/routes.js +0 -256
- package/src/running-browser.js +0 -85
- package/src/scroll-collect.js +0 -73
- package/src/serial-emitter.js +0 -17
- package/src/shared-connections.js +0 -285
- package/src/snapshot-diff.js +0 -75
- package/src/text-matching.js +0 -101
- package/src/trace.js +0 -183
- package/src/url-match.js +0 -148
- package/src/viewport.js +0 -12
package/dist/cua.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface CuaPoint {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export interface CuaPage {
|
|
6
|
+
keyboard: {
|
|
7
|
+
down(key: string): Promise<unknown>;
|
|
8
|
+
up(key: string): Promise<unknown>;
|
|
9
|
+
press(key: string): Promise<unknown>;
|
|
10
|
+
type(text: string): Promise<unknown>;
|
|
11
|
+
};
|
|
12
|
+
mouse: {
|
|
13
|
+
click(x: number, y: number, options?: {
|
|
14
|
+
button?: string;
|
|
15
|
+
clickCount?: number;
|
|
16
|
+
}): Promise<unknown>;
|
|
17
|
+
move(x: number, y: number): Promise<unknown>;
|
|
18
|
+
down(): Promise<unknown>;
|
|
19
|
+
up(): Promise<unknown>;
|
|
20
|
+
wheel(deltaX: number, deltaY: number): Promise<unknown>;
|
|
21
|
+
};
|
|
22
|
+
screenshot(options: {
|
|
23
|
+
type: "png";
|
|
24
|
+
}): Promise<{
|
|
25
|
+
toString(encoding: "base64"): string;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
export declare function createCua<P extends CuaPage>(page: P): {
|
|
29
|
+
page: P;
|
|
30
|
+
click({ x, y, button, keypress }: CuaPoint & {
|
|
31
|
+
button?: string;
|
|
32
|
+
keypress?: string[];
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
doubleClick({ x, y, keypress }: CuaPoint & {
|
|
35
|
+
keypress?: string[];
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
drag({ path, keys }: {
|
|
38
|
+
path: [CuaPoint, CuaPoint, ...CuaPoint[]];
|
|
39
|
+
keys?: string[];
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
getVisibleScreenshot(): Promise<string>;
|
|
42
|
+
keypress({ keys }: {
|
|
43
|
+
keys: string[];
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
move({ x, y, keys }: CuaPoint & {
|
|
46
|
+
keys?: string[];
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
scroll({ x, y, scrollX, scrollY, keypress, }: CuaPoint & {
|
|
49
|
+
scrollX: number;
|
|
50
|
+
scrollY: number;
|
|
51
|
+
keypress?: string[];
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
type({ text }: {
|
|
54
|
+
text: string;
|
|
55
|
+
}): Promise<void>;
|
|
56
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface DialogOpeningParams {
|
|
2
|
+
type?: string;
|
|
3
|
+
message?: string;
|
|
4
|
+
defaultPrompt?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DialogInfo {
|
|
8
|
+
type: string | undefined;
|
|
9
|
+
message: string | undefined;
|
|
10
|
+
defaultPrompt: string;
|
|
11
|
+
url: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface DialogDecision {
|
|
14
|
+
accept: boolean;
|
|
15
|
+
promptText?: string;
|
|
16
|
+
}
|
|
17
|
+
export type DialogPolicyResult = boolean | {
|
|
18
|
+
accept?: boolean;
|
|
19
|
+
promptText?: string;
|
|
20
|
+
} | null | undefined;
|
|
21
|
+
export type DialogPolicy = DialogPolicyResult | ((dialog: DialogInfo) => DialogPolicyResult | Promise<DialogPolicyResult>);
|
|
22
|
+
export type DialogSend = (action: DialogDecision) => unknown;
|
|
23
|
+
export declare function normalizeDialogPolicy(policy: DialogPolicy): boolean | {
|
|
24
|
+
accept?: boolean;
|
|
25
|
+
promptText?: string;
|
|
26
|
+
} | ((dialog: DialogInfo) => DialogPolicyResult | Promise<DialogPolicyResult>);
|
|
27
|
+
export declare function resolveDialogAction(policy: DialogPolicy, params?: DialogOpeningParams): Promise<DialogDecision>;
|
|
28
|
+
export declare class Dialog {
|
|
29
|
+
#private;
|
|
30
|
+
constructor(params: DialogOpeningParams | null | undefined, send: DialogSend);
|
|
31
|
+
get url(): string | undefined;
|
|
32
|
+
type(): string | undefined;
|
|
33
|
+
message(): string | undefined;
|
|
34
|
+
defaultValue(): string;
|
|
35
|
+
accept(promptText?: string): Promise<void>;
|
|
36
|
+
dismiss(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The value `answerWithPolicy` wants: CDP can hand the same event a non-object,
|
|
40
|
+
* and its signature takes no null. Shared so core and the ego client agree.
|
|
41
|
+
*/
|
|
42
|
+
export declare function dialogPolicyParams(params: unknown): DialogOpeningParams | undefined;
|
|
43
|
+
export declare function answerWithPolicy(dialog: Dialog, policy: DialogPolicy, params?: DialogOpeningParams): Promise<void>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Dialog, normalizeDialogPolicy } from "../dialog-policy.js";
|
|
2
|
+
export type DialogPolicyInput = Parameters<typeof normalizeDialogPolicy>[0];
|
|
3
|
+
export interface EgoCdpBindings {
|
|
4
|
+
sendCDPMessage(message: string): unknown;
|
|
5
|
+
onCDPMessage?: ((payload: string) => unknown) | undefined;
|
|
6
|
+
onSendCDPMessageError?: ((message: string, code?: string) => unknown) | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface EgoTaskSpace {
|
|
9
|
+
readonly [key: string]: unknown;
|
|
10
|
+
id: number;
|
|
11
|
+
error?: unknown;
|
|
12
|
+
error_code?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface EgoBindings extends EgoCdpBindings {
|
|
15
|
+
createTaskSpace?: ((name: string, profileId?: string) => EgoTaskSpace | null | undefined | Promise<EgoTaskSpace | null | undefined>) | undefined;
|
|
16
|
+
useTaskSpace(id: number): unknown;
|
|
17
|
+
}
|
|
18
|
+
declare global {
|
|
19
|
+
var ego: EgoBindings | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface EgoCdpErrorOptions {
|
|
22
|
+
method?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface EgoCdpClientOptions {
|
|
25
|
+
ego?: EgoCdpBindings | undefined;
|
|
26
|
+
commandTimeoutMs?: number | undefined;
|
|
27
|
+
logId?: string | undefined;
|
|
28
|
+
dialogPolicy?: DialogPolicyInput;
|
|
29
|
+
}
|
|
30
|
+
export interface EgoSendOptions {
|
|
31
|
+
capability?: symbol;
|
|
32
|
+
timeoutMs?: number | undefined;
|
|
33
|
+
}
|
|
34
|
+
export interface EgoEventMeta {
|
|
35
|
+
sessionId: string | undefined;
|
|
36
|
+
dialog?: Dialog;
|
|
37
|
+
}
|
|
38
|
+
export interface EgoEvent {
|
|
39
|
+
data: {
|
|
40
|
+
payload: unknown;
|
|
41
|
+
meta: EgoEventMeta;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export interface PendingCommand {
|
|
45
|
+
method: string;
|
|
46
|
+
sessionId: string | undefined;
|
|
47
|
+
resolve: (value: unknown) => void;
|
|
48
|
+
reject: (reason: unknown) => void;
|
|
49
|
+
timeout: ReturnType<typeof setTimeout> | undefined;
|
|
50
|
+
}
|
|
51
|
+
export interface EgoTarget {
|
|
52
|
+
id: string | undefined;
|
|
53
|
+
type: string | undefined;
|
|
54
|
+
url: string;
|
|
55
|
+
title: string;
|
|
56
|
+
description: string | undefined;
|
|
57
|
+
faviconUrl: string | undefined;
|
|
58
|
+
parentId: string | undefined;
|
|
59
|
+
}
|
|
60
|
+
export interface TaskSpaceSelection {
|
|
61
|
+
taskSpace?: number | undefined;
|
|
62
|
+
taskName?: string | undefined;
|
|
63
|
+
profileId?: string | undefined;
|
|
64
|
+
}
|
|
65
|
+
export interface ConnectEgoOptions extends EgoCdpClientOptions, TaskSpaceSelection {
|
|
66
|
+
ego?: EgoBindings | undefined;
|
|
67
|
+
storageRoot?: string | undefined;
|
|
68
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CdpEventPayload, CdpResult, CdpTargetSummary } from "../cdp-protocol.js";
|
|
2
|
+
import type { DialogPolicyInput, EgoCdpClientOptions, EgoEventMeta, EgoSendOptions } from "./bindings.js";
|
|
3
|
+
import { SerialEmitter as Emittery } from "../serial-emitter.js";
|
|
4
|
+
export declare class EgoCdpClient {
|
|
5
|
+
#private;
|
|
6
|
+
transportEvents: Emittery<unknown>;
|
|
7
|
+
logId: string;
|
|
8
|
+
isHeadless: boolean;
|
|
9
|
+
constructor({ ego, commandTimeoutMs, logId, dialogPolicy }?: EgoCdpClientOptions);
|
|
10
|
+
get isConnected(): boolean;
|
|
11
|
+
get dialogPolicy(): boolean | {
|
|
12
|
+
accept?: boolean;
|
|
13
|
+
promptText?: string;
|
|
14
|
+
} | ((dialog: import("../dialog-policy.js").DialogInfo) => import("../dialog-policy.js").DialogPolicyResult | Promise<import("../dialog-policy.js").DialogPolicyResult>);
|
|
15
|
+
setDialogPolicy(policy: DialogPolicyInput): void;
|
|
16
|
+
ensureConnected(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Overload declaration + loose implementation, the repo's idiom for a generic
|
|
19
|
+
* transport surface: a concrete client cannot return a caller-chosen CdpResult<M>
|
|
20
|
+
* from a concrete body, and a cast to fake it is banned by the lint ratchet.
|
|
21
|
+
*/
|
|
22
|
+
send<M extends string>(method: M, params?: object, sessionId?: string, opts?: EgoSendOptions): Promise<CdpResult<M>>;
|
|
23
|
+
/** Overload declaration + loose body, same idiom as send: no cast needed. */
|
|
24
|
+
on<E extends string>(event: E, handler: (payload: CdpEventPayload<E>, meta: EgoEventMeta) => unknown): () => void;
|
|
25
|
+
discoverTargets(): Promise<CdpTargetSummary[]>;
|
|
26
|
+
closeSession(sessionId: string): void;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BrowserConnection } from "../connection.js";
|
|
2
|
+
import type { ConnectEgoOptions, EgoTaskSpace } from "./bindings.js";
|
|
3
|
+
export { EgoCdpClient } from "./cdp-client.js";
|
|
4
|
+
export { EgoCdpError } from "./errors.js";
|
|
5
|
+
export declare function connectEgo({ ego: egoOption, taskSpace, taskName, profileId, storageRoot, commandTimeoutMs, logId, dialogPolicy, }?: ConnectEgoOptions): Promise<BrowserConnection & {
|
|
6
|
+
engine: "ego";
|
|
7
|
+
taskSpace: EgoTaskSpace;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EgoCdpBindings, EgoCdpErrorOptions } from "./bindings.js";
|
|
2
|
+
export declare function requireEgo<T extends EgoCdpBindings>(ego: T | undefined): T;
|
|
3
|
+
export declare class EgoCdpError extends Error {
|
|
4
|
+
code: string;
|
|
5
|
+
method?: string;
|
|
6
|
+
constructor(code: string, message: string, { method }?: EgoCdpErrorOptions);
|
|
7
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface DevicePreset {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
deviceScaleFactor: number;
|
|
5
|
+
mobile: boolean;
|
|
6
|
+
hasTouch: boolean;
|
|
7
|
+
userAgent: string | undefined;
|
|
8
|
+
platform: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface EmulatePage {
|
|
11
|
+
resolveSessionId(): Promise<string | undefined>;
|
|
12
|
+
cdp: {
|
|
13
|
+
send(method: string, params: Record<string, unknown>, sessionId?: string): Promise<unknown>;
|
|
14
|
+
};
|
|
15
|
+
evaluate<T>(pageFunction: () => T): Promise<T>;
|
|
16
|
+
refreshViewportSize?: () => Promise<unknown>;
|
|
17
|
+
}
|
|
18
|
+
export declare const DEVICE_PRESETS: Readonly<{
|
|
19
|
+
"iphone-14": {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
deviceScaleFactor: number;
|
|
23
|
+
mobile: true;
|
|
24
|
+
hasTouch: true;
|
|
25
|
+
userAgent: string;
|
|
26
|
+
platform: string;
|
|
27
|
+
};
|
|
28
|
+
"pixel-7": {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
deviceScaleFactor: number;
|
|
32
|
+
mobile: true;
|
|
33
|
+
hasTouch: true;
|
|
34
|
+
userAgent: string;
|
|
35
|
+
platform: string;
|
|
36
|
+
};
|
|
37
|
+
"ipad-air": {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
deviceScaleFactor: number;
|
|
41
|
+
mobile: true;
|
|
42
|
+
hasTouch: true;
|
|
43
|
+
userAgent: string;
|
|
44
|
+
platform: string;
|
|
45
|
+
};
|
|
46
|
+
"desktop-1440": {
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
deviceScaleFactor: number;
|
|
50
|
+
mobile: false;
|
|
51
|
+
hasTouch: false;
|
|
52
|
+
userAgent: undefined;
|
|
53
|
+
platform: undefined;
|
|
54
|
+
};
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Emulate a device on the given page.
|
|
58
|
+
* @param {object} page - The page object with cdp.send(), resolveSessionId(), evaluate(), refreshViewportSize()
|
|
59
|
+
* @param {string|object|null} presetNameOrObject - Preset name, object, or null to restore
|
|
60
|
+
* @returns {object} The resolved preset object
|
|
61
|
+
*/
|
|
62
|
+
export declare function emulate(page: EmulatePage, presetNameOrObject: string | DevicePreset | null): Promise<DevicePreset | null>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { connectAside } from "./aside/session.js";
|
|
2
|
+
import type { ConnectAsideOptions } from "./aside/session-types.js";
|
|
3
|
+
import { connectEgo } from "./ego/client.js";
|
|
4
|
+
import type { ConnectEgoOptions } from "./ego/bindings.js";
|
|
5
|
+
import { connectBrowserSkill } from "./bsk/connect.js";
|
|
6
|
+
import type { ConnectBrowserSkillOptions } from "./bsk/connect.js";
|
|
7
|
+
import { connectCloakProfile } from "./cloak-profile.js";
|
|
8
|
+
import type { CloakConnectOptions } from "./cloak-profile.js";
|
|
9
|
+
/** Each engine's own connect options, passed through by connectBrowser under the engine's name. */
|
|
10
|
+
export interface EngineOptions {
|
|
11
|
+
aside: ConnectAsideOptions;
|
|
12
|
+
ego: ConnectEgoOptions;
|
|
13
|
+
bsk: ConnectBrowserSkillOptions;
|
|
14
|
+
cloak: CloakConnectOptions;
|
|
15
|
+
}
|
|
16
|
+
export type EngineName = keyof EngineOptions;
|
|
17
|
+
interface EngineHandles {
|
|
18
|
+
aside: Awaited<ReturnType<typeof connectAside>>;
|
|
19
|
+
ego: Awaited<ReturnType<typeof connectEgo>>;
|
|
20
|
+
bsk: Awaited<ReturnType<typeof connectBrowserSkill>>;
|
|
21
|
+
cloak: Awaited<ReturnType<typeof connectCloakProfile>>;
|
|
22
|
+
}
|
|
23
|
+
/** One engine's outcome: when it attached, how that was verified; when it did not, why. */
|
|
24
|
+
export interface EngineAttempt {
|
|
25
|
+
engine: EngineName;
|
|
26
|
+
ok: boolean;
|
|
27
|
+
/** Time spent connecting and verifying; absent for engines that were not run. */
|
|
28
|
+
ms?: number;
|
|
29
|
+
/** The check that proved attachment. */
|
|
30
|
+
verified?: string;
|
|
31
|
+
reason?: string;
|
|
32
|
+
}
|
|
33
|
+
type AnyHandle = EngineHandles[EngineName];
|
|
34
|
+
export interface ConnectBrowserOptions extends Partial<EngineOptions> {
|
|
35
|
+
/** Tried first; any other value throws a TypeError. */
|
|
36
|
+
prefer?: string | undefined;
|
|
37
|
+
/** Engines allowed to run; any other name throws a TypeError. */
|
|
38
|
+
allow?: readonly string[] | undefined;
|
|
39
|
+
/** Also attach every other allowed engine, for comparison only (each is a second browser). */
|
|
40
|
+
crossCheck?: boolean | undefined;
|
|
41
|
+
}
|
|
42
|
+
export declare const ENGINE_ORDER: readonly EngineName[];
|
|
43
|
+
export declare class NoBrowserEngineError extends Error {
|
|
44
|
+
code: string;
|
|
45
|
+
attempts: EngineAttempt[];
|
|
46
|
+
constructor(attempts: EngineAttempt[]);
|
|
47
|
+
}
|
|
48
|
+
export declare function connectBrowser({ prefer, allow, crossCheck, ...perEngine }?: ConnectBrowserOptions): Promise<{
|
|
49
|
+
engine: keyof EngineOptions;
|
|
50
|
+
handle: AnyHandle;
|
|
51
|
+
attempts: EngineAttempt[];
|
|
52
|
+
attached: (keyof EngineOptions)[];
|
|
53
|
+
crossCheck: {
|
|
54
|
+
engine: EngineName;
|
|
55
|
+
handle: AnyHandle;
|
|
56
|
+
}[];
|
|
57
|
+
closeAll: () => Promise<void>;
|
|
58
|
+
}>;
|
|
59
|
+
export {};
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { CdpEventPayload, CdpTransport } from "./cdp-protocol.js";
|
|
2
|
+
export type BrowserEventName = "tabOpened" | "tabClosed" | "popupOpened" | "downloadStarted" | "downloadProgress" | "downloadFinished";
|
|
3
|
+
export declare const BROWSER_EVENT_NAMES: readonly BrowserEventName[];
|
|
4
|
+
export type DownloadBehavior = "default" | "allow" | "deny" | "allowAndName";
|
|
5
|
+
type CdpDownloadState = CdpEventPayload<"Browser.downloadProgress">["state"];
|
|
6
|
+
export interface BrowserEventsOptions {
|
|
7
|
+
downloadBehavior?: DownloadBehavior;
|
|
8
|
+
/** Absolute path; required when `downloadBehavior` is "allow". */
|
|
9
|
+
downloadPath?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface BrowserEventsConnection {
|
|
12
|
+
readonly cdp: Pick<CdpTransport, "ensureConnected" | "on" | "send" | "transportEvents">;
|
|
13
|
+
}
|
|
14
|
+
export interface BrowserTabTarget {
|
|
15
|
+
targetId: string;
|
|
16
|
+
type: "page";
|
|
17
|
+
url: string;
|
|
18
|
+
title: string;
|
|
19
|
+
openerId: string | null;
|
|
20
|
+
openerFrameId: string | null;
|
|
21
|
+
browserContextId: string | null;
|
|
22
|
+
attached: boolean;
|
|
23
|
+
subtype: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface BrowserDownloadError {
|
|
26
|
+
code: "browserDisconnected";
|
|
27
|
+
message: string;
|
|
28
|
+
}
|
|
29
|
+
export interface BrowserEventPayloads {
|
|
30
|
+
tabOpened: BrowserTabTarget & {
|
|
31
|
+
popup: boolean;
|
|
32
|
+
initial: boolean;
|
|
33
|
+
};
|
|
34
|
+
tabClosed: {
|
|
35
|
+
targetId: string;
|
|
36
|
+
reason: "crashed" | "destroyed";
|
|
37
|
+
lastKnown: BrowserTabTarget;
|
|
38
|
+
crash: TargetCrash | null;
|
|
39
|
+
};
|
|
40
|
+
popupOpened: {
|
|
41
|
+
targetId: string;
|
|
42
|
+
openerTargetId: string | null;
|
|
43
|
+
openerFrameId: string | null;
|
|
44
|
+
url: string;
|
|
45
|
+
title: string;
|
|
46
|
+
initial: boolean;
|
|
47
|
+
};
|
|
48
|
+
downloadStarted: {
|
|
49
|
+
guid: string;
|
|
50
|
+
url: string | null;
|
|
51
|
+
suggestedFilename: string;
|
|
52
|
+
frameId: string | null;
|
|
53
|
+
targetId: string | null;
|
|
54
|
+
};
|
|
55
|
+
downloadProgress: {
|
|
56
|
+
guid: string;
|
|
57
|
+
totalBytes: number;
|
|
58
|
+
receivedBytes: number;
|
|
59
|
+
state: CdpDownloadState | undefined;
|
|
60
|
+
filePath: string | null;
|
|
61
|
+
targetId: string | null;
|
|
62
|
+
};
|
|
63
|
+
downloadFinished: {
|
|
64
|
+
guid: string;
|
|
65
|
+
totalBytes: number;
|
|
66
|
+
receivedBytes: number;
|
|
67
|
+
state: "completed" | "canceled" | "failed";
|
|
68
|
+
cdpState: CdpDownloadState | null;
|
|
69
|
+
filePath: string | null;
|
|
70
|
+
targetId: string | null;
|
|
71
|
+
error: BrowserDownloadError | null;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export type BrowserEventListener<N extends BrowserEventName> = (payload: BrowserEventPayloads[N]) => unknown;
|
|
75
|
+
export interface WaitForBrowserEventOptions<N extends BrowserEventName> {
|
|
76
|
+
timeout?: number;
|
|
77
|
+
predicate?: (payload: BrowserEventPayloads[N]) => unknown;
|
|
78
|
+
}
|
|
79
|
+
interface TargetCrash {
|
|
80
|
+
status: string;
|
|
81
|
+
errorCode: number;
|
|
82
|
+
}
|
|
83
|
+
declare class BrowserEventBridge {
|
|
84
|
+
#private;
|
|
85
|
+
ready: Promise<void>;
|
|
86
|
+
constructor(connection: BrowserEventsConnection, options: BrowserEventsOptions);
|
|
87
|
+
on<N extends BrowserEventName>(name: N, listener: BrowserEventListener<N>): () => void;
|
|
88
|
+
off<N extends BrowserEventName>(name: N, listener: BrowserEventListener<N>): void;
|
|
89
|
+
waitForEvent<N extends BrowserEventName>(name: N, options?: WaitForBrowserEventOptions<N>): Promise<BrowserEventPayloads[N]>;
|
|
90
|
+
dispose(): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
export declare function createEvents(connection: BrowserEventsConnection, options?: BrowserEventsOptions): BrowserEventBridge;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { CdpSend } from "./cdp-protocol.js";
|
|
2
|
+
export interface FrameTargetInfo {
|
|
3
|
+
targetId: string;
|
|
4
|
+
type: string;
|
|
5
|
+
browserContextId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FrameEntry {
|
|
8
|
+
frameId: string;
|
|
9
|
+
parentFrameId: string | null;
|
|
10
|
+
url: string;
|
|
11
|
+
name?: string | undefined;
|
|
12
|
+
sessionId?: string | undefined;
|
|
13
|
+
isolatedContextId?: number | null | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface FrameManagerView {
|
|
16
|
+
frames: Map<string, FrameEntry>;
|
|
17
|
+
mainFrameId: string | null;
|
|
18
|
+
getFrame(frameId: string): FrameEntry | null | undefined;
|
|
19
|
+
collectDescendantFrames(frameId: string | null): ReadonlyArray<{
|
|
20
|
+
frameId: string;
|
|
21
|
+
}>;
|
|
22
|
+
ensureInjected(frameId: string): Promise<number | null>;
|
|
23
|
+
}
|
|
24
|
+
export interface FramesPage<S extends FramesSnapshot = FramesSnapshot> {
|
|
25
|
+
targetId: string;
|
|
26
|
+
cdp: {
|
|
27
|
+
send: CdpSend;
|
|
28
|
+
};
|
|
29
|
+
frameManager: FrameManagerView;
|
|
30
|
+
snapshot(options?: object): Promise<S>;
|
|
31
|
+
}
|
|
32
|
+
export interface FramesSnapshot {
|
|
33
|
+
refs?: Readonly<Record<string, unknown>> | null | undefined;
|
|
34
|
+
}
|
|
35
|
+
export interface AdoptedFrame {
|
|
36
|
+
frameId: string;
|
|
37
|
+
parentFrameId: string;
|
|
38
|
+
url: string;
|
|
39
|
+
sessionId: string;
|
|
40
|
+
isolatedContextId: unknown;
|
|
41
|
+
}
|
|
42
|
+
export interface MissingFrame {
|
|
43
|
+
frameId: string;
|
|
44
|
+
url: string;
|
|
45
|
+
injected: false;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Adopt every iframe target of this page that FrameManager does not know yet.
|
|
49
|
+
* Returns the frames that were added (empty when there was nothing to recover).
|
|
50
|
+
*/
|
|
51
|
+
export declare function reconcileFrames(page: FramesPage): Promise<AdoptedFrame[]>;
|
|
52
|
+
/**
|
|
53
|
+
* page.snapshot() with pre-existing out-of-process iframes recovered first.
|
|
54
|
+
* Adds `missingFrames` only when a frame could not be entered at all.
|
|
55
|
+
*/
|
|
56
|
+
export declare function snapshotWithFrames<S extends FramesSnapshot>(page: FramesPage<S>, opts?: object): Promise<S | (S & {
|
|
57
|
+
missingFrames: MissingFrame[];
|
|
58
|
+
})>;
|
package/dist/har.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export type HeaderMap = Readonly<Record<string, unknown>>;
|
|
2
|
+
export interface HarSourceEntry {
|
|
3
|
+
startedAt?: unknown;
|
|
4
|
+
finishedAt?: unknown;
|
|
5
|
+
method?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
postData?: string | null;
|
|
8
|
+
requestHeaders?: HeaderMap | null;
|
|
9
|
+
responseHeaders?: HeaderMap | null;
|
|
10
|
+
encodedDataLength?: number | null;
|
|
11
|
+
mimeType?: string | null;
|
|
12
|
+
body?: unknown;
|
|
13
|
+
base64Encoded?: boolean;
|
|
14
|
+
failed?: boolean;
|
|
15
|
+
status?: number | null;
|
|
16
|
+
statusText?: string | null;
|
|
17
|
+
errorText?: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface HarNameValue {
|
|
20
|
+
name: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
export interface HarRequest {
|
|
24
|
+
method: string;
|
|
25
|
+
url: string;
|
|
26
|
+
httpVersion: string;
|
|
27
|
+
cookies: HarNameValue[];
|
|
28
|
+
headers: HarNameValue[];
|
|
29
|
+
queryString: HarNameValue[];
|
|
30
|
+
headersSize: number;
|
|
31
|
+
bodySize: number;
|
|
32
|
+
postData?: {
|
|
33
|
+
mimeType: string;
|
|
34
|
+
text: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface HarContent {
|
|
38
|
+
size: number;
|
|
39
|
+
mimeType: string;
|
|
40
|
+
text?: string;
|
|
41
|
+
encoding?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface HarResponse {
|
|
44
|
+
status: number;
|
|
45
|
+
statusText: string;
|
|
46
|
+
httpVersion: string;
|
|
47
|
+
cookies: HarNameValue[];
|
|
48
|
+
headers: HarNameValue[];
|
|
49
|
+
content: HarContent;
|
|
50
|
+
redirectURL: string;
|
|
51
|
+
headersSize: number;
|
|
52
|
+
bodySize: number;
|
|
53
|
+
}
|
|
54
|
+
export interface HarEntry {
|
|
55
|
+
startedDateTime: string;
|
|
56
|
+
time: number;
|
|
57
|
+
request: HarRequest;
|
|
58
|
+
response: HarResponse;
|
|
59
|
+
cache: Record<string, never>;
|
|
60
|
+
timings: {
|
|
61
|
+
send: number;
|
|
62
|
+
wait: number;
|
|
63
|
+
receive: number;
|
|
64
|
+
};
|
|
65
|
+
_errorText?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface HarCreator {
|
|
68
|
+
name: string;
|
|
69
|
+
version: string;
|
|
70
|
+
}
|
|
71
|
+
export interface ToHarOptions {
|
|
72
|
+
creator?: HarCreator;
|
|
73
|
+
pages?: unknown[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Converts network snoop entries into a HAR 1.2 log.
|
|
77
|
+
*
|
|
78
|
+
* Pure: it touches no disk and mutates nothing, so callers can serialize the result
|
|
79
|
+
* themselves or embed it in a larger artifact.
|
|
80
|
+
*/
|
|
81
|
+
export declare function toHar(entries: Iterable<HarSourceEntry> | null | undefined, { creator, pages }?: ToHarOptions): {
|
|
82
|
+
log: {
|
|
83
|
+
version: string;
|
|
84
|
+
creator: HarCreator;
|
|
85
|
+
pages: unknown[];
|
|
86
|
+
entries: HarEntry[];
|
|
87
|
+
};
|
|
88
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
__omowrightHumanDone?: boolean | undefined;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/** What requestHuman drives on a page; omowright's Page satisfies it. */
|
|
7
|
+
export interface HumanPage {
|
|
8
|
+
url(): string;
|
|
9
|
+
bringToFront(): Promise<unknown>;
|
|
10
|
+
evaluate(pageFunction: () => unknown): Promise<unknown>;
|
|
11
|
+
evaluate<A>(pageFunction: (arg: A) => unknown, arg: A): Promise<unknown>;
|
|
12
|
+
}
|
|
13
|
+
/** Continue once the page URL matches, a selector exists, or a predicate holds. */
|
|
14
|
+
export type HumanUntil<P> = ((page: P) => unknown) | {
|
|
15
|
+
readonly url?: string | RegExp;
|
|
16
|
+
readonly selector?: string;
|
|
17
|
+
} | null | undefined;
|
|
18
|
+
export interface HumanRequest<P> {
|
|
19
|
+
prompt?: string | null | undefined;
|
|
20
|
+
until?: HumanUntil<P>;
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
pollMs?: number;
|
|
23
|
+
signal?: AbortSignal | undefined;
|
|
24
|
+
}
|
|
25
|
+
export type HumanOutcome = "continued" | "cancelled" | "timed_out";
|
|
26
|
+
export declare function requestHuman<P extends HumanPage>(page: P, { prompt, until, timeoutMs, pollMs, signal }?: HumanRequest<P>): Promise<{
|
|
27
|
+
outcome: HumanOutcome;
|
|
28
|
+
elapsedMs: number;
|
|
29
|
+
reason: string;
|
|
30
|
+
}>;
|