@mearl/native-host 2.7.2 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +903 -32513
- package/dist/install.js +9 -268
- package/package.json +12 -7
- package/dist/agent/codex-provider.d.ts +0 -60
- package/dist/agent/event-transport.d.ts +0 -3
- package/dist/agent/executable-resolver.d.ts +0 -46
- package/dist/agent/manager.d.ts +0 -41
- package/dist/agent/process-env.d.ts +0 -2
- package/dist/agent/provider.d.ts +0 -47
- package/dist/agent/qoder-provider.d.ts +0 -65
- package/dist/agent/skill-manager.d.ts +0 -21
- package/dist/agent/workspace-directory.d.ts +0 -4
- package/dist/agentbay-browser.d.ts +0 -168
- package/dist/agentbay-file-upload.d.ts +0 -12
- package/dist/agentbay-lifecycle.d.ts +0 -38
- package/dist/analytics.d.ts +0 -3
- package/dist/browser-inventory.d.ts +0 -8
- package/dist/browser-registry.d.ts +0 -78
- package/dist/cdp-backend/action-registry.d.ts +0 -36
- package/dist/cdp-backend/browser-handlers.d.ts +0 -8
- package/dist/cdp-backend/buffers.d.ts +0 -53
- package/dist/cdp-backend/cdp-session.d.ts +0 -74
- package/dist/cdp-backend/cdp-utils.d.ts +0 -67
- package/dist/cdp-backend/client.d.ts +0 -34
- package/dist/cdp-backend/composite-handlers.d.ts +0 -17
- package/dist/cdp-backend/controlled-indicator.d.ts +0 -18
- package/dist/cdp-backend/cookie-handlers.d.ts +0 -5
- package/dist/cdp-backend/cookie-transfer.d.ts +0 -30
- package/dist/cdp-backend/discover.d.ts +0 -28
- package/dist/cdp-backend/domain-manager.d.ts +0 -4
- package/dist/cdp-backend/handlers.d.ts +0 -31
- package/dist/cdp-backend/http-handlers.d.ts +0 -8
- package/dist/cdp-backend/interaction-handlers.d.ts +0 -18
- package/dist/cdp-backend/mock-handlers.d.ts +0 -9
- package/dist/cdp-backend/navigation-observer.d.ts +0 -9
- package/dist/cdp-backend/page-observer.d.ts +0 -5
- package/dist/cdp-backend/page-refs.d.ts +0 -9
- package/dist/cdp-backend/recording-handlers.d.ts +0 -12
- package/dist/cdp-backend/release-control.d.ts +0 -13
- package/dist/cdp-backend/request-handlers.d.ts +0 -10
- package/dist/cdp-backend/send-request.d.ts +0 -2
- package/dist/cdp-backend/snapshot-handlers.d.ts +0 -7
- package/dist/cdp-backend/tab-handlers.d.ts +0 -8
- package/dist/cdp-backend/tdbank-handlers.d.ts +0 -14
- package/dist/cdp-backend/timezone-handlers.d.ts +0 -4
- package/dist/cloud-connector.d.ts +0 -61
- package/dist/extension-file-transfer.d.ts +0 -7
- package/dist/host-updater.d.ts +0 -39
- package/dist/index.d.ts +0 -2
- package/dist/internal-extension-actions.d.ts +0 -9
- package/dist/managed-browser.d.ts +0 -78
- package/dist/send-request-file-utils.d.ts +0 -14
- package/dist/version.d.ts +0 -1
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/** AgentBay browser lifecycle and CDP endpoint resolution. */
|
|
2
|
-
import { type DaemonRecord } from '@mearl/daemon-core';
|
|
3
|
-
import type { BrowserLaunchParams } from '@mearl/browser-core';
|
|
4
|
-
import { type TransferableCookie } from './cdp-backend/cookie-transfer.js';
|
|
5
|
-
export declare const DEFAULT_AGENTBAY_IMAGE_ID = "imgc-0aae4rgl8kvagdv1j";
|
|
6
|
-
export interface AgentBayBrowserRecord extends DaemonRecord {
|
|
7
|
-
pid: number;
|
|
8
|
-
browserId: string;
|
|
9
|
-
name: string;
|
|
10
|
-
sessionId: string;
|
|
11
|
-
imageId?: string;
|
|
12
|
-
userAgentMode?: 'default' | 'desktop';
|
|
13
|
-
persistent?: boolean;
|
|
14
|
-
contextId?: string;
|
|
15
|
-
contextName?: string;
|
|
16
|
-
/** Successful context sync checkpoint for retrying deletion of the current session. */
|
|
17
|
-
contextSyncedAt?: string;
|
|
18
|
-
createdAt: string;
|
|
19
|
-
copiedCookies?: {
|
|
20
|
-
domains: string[];
|
|
21
|
-
count: number;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export interface AgentBaySessionLike {
|
|
25
|
-
sessionId: string;
|
|
26
|
-
browser: {
|
|
27
|
-
initializeAsync(options: Record<string, unknown>): Promise<boolean>;
|
|
28
|
-
getEndpointUrl(): Promise<string>;
|
|
29
|
-
};
|
|
30
|
-
info?(): Promise<{
|
|
31
|
-
success?: boolean;
|
|
32
|
-
data?: unknown;
|
|
33
|
-
errorMessage?: string;
|
|
34
|
-
}>;
|
|
35
|
-
callMcpTool?(toolName: string, args: Record<string, unknown>, autoGenSession?: boolean): Promise<{
|
|
36
|
-
success?: boolean;
|
|
37
|
-
errorMessage?: string;
|
|
38
|
-
}>;
|
|
39
|
-
context?: {
|
|
40
|
-
sync(): Promise<{
|
|
41
|
-
success: boolean;
|
|
42
|
-
errorMessage?: string;
|
|
43
|
-
}>;
|
|
44
|
-
};
|
|
45
|
-
fileSystem?: {
|
|
46
|
-
getFileTransferContextPath(): Promise<string | null>;
|
|
47
|
-
createDirectory(path: string): Promise<{
|
|
48
|
-
success?: boolean;
|
|
49
|
-
error?: string;
|
|
50
|
-
errorMessage?: string;
|
|
51
|
-
}>;
|
|
52
|
-
uploadFile(localPath: string, remotePath: string, options?: {
|
|
53
|
-
wait?: boolean;
|
|
54
|
-
waitTimeout?: number;
|
|
55
|
-
}): Promise<{
|
|
56
|
-
success?: boolean;
|
|
57
|
-
error?: string;
|
|
58
|
-
errorMessage?: string;
|
|
59
|
-
error_message?: string;
|
|
60
|
-
}>;
|
|
61
|
-
};
|
|
62
|
-
delete(syncContext?: boolean): Promise<{
|
|
63
|
-
success: boolean;
|
|
64
|
-
errorMessage?: string;
|
|
65
|
-
}>;
|
|
66
|
-
keepAlive(): Promise<{
|
|
67
|
-
success?: boolean;
|
|
68
|
-
errorMessage?: string;
|
|
69
|
-
}>;
|
|
70
|
-
}
|
|
71
|
-
export interface AgentBayClientLike {
|
|
72
|
-
create(params: Record<string, unknown>): Promise<{
|
|
73
|
-
success: boolean;
|
|
74
|
-
session?: AgentBaySessionLike;
|
|
75
|
-
errorMessage?: string;
|
|
76
|
-
}>;
|
|
77
|
-
get(sessionId: string): Promise<{
|
|
78
|
-
success: boolean;
|
|
79
|
-
session?: AgentBaySessionLike;
|
|
80
|
-
errorMessage?: string;
|
|
81
|
-
}>;
|
|
82
|
-
context?: {
|
|
83
|
-
get(name: string, create?: boolean): Promise<{
|
|
84
|
-
success: boolean;
|
|
85
|
-
context?: {
|
|
86
|
-
id: string;
|
|
87
|
-
name: string;
|
|
88
|
-
};
|
|
89
|
-
errorMessage?: string;
|
|
90
|
-
}>;
|
|
91
|
-
delete(context: {
|
|
92
|
-
id: string;
|
|
93
|
-
name: string;
|
|
94
|
-
}): Promise<{
|
|
95
|
-
success: boolean;
|
|
96
|
-
errorMessage?: string;
|
|
97
|
-
}>;
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
export interface AgentBayBrowserSummary {
|
|
101
|
-
browserId: string;
|
|
102
|
-
name: string;
|
|
103
|
-
provider: 'agentbay';
|
|
104
|
-
headless: false;
|
|
105
|
-
persistent: boolean;
|
|
106
|
-
agentbaySessionId: string;
|
|
107
|
-
agentbayImageId?: string;
|
|
108
|
-
agentbayContextId?: string;
|
|
109
|
-
agentbayContextName?: string;
|
|
110
|
-
createdAt: string;
|
|
111
|
-
copiedCookies?: AgentBayBrowserRecord['copiedCookies'];
|
|
112
|
-
running: boolean;
|
|
113
|
-
}
|
|
114
|
-
export interface AgentBayBrowserLaunchResult extends AgentBayBrowserSummary {
|
|
115
|
-
created: boolean;
|
|
116
|
-
reused: boolean;
|
|
117
|
-
}
|
|
118
|
-
export interface AgentBayBrowserManagerDeps {
|
|
119
|
-
nativeHostScript: string;
|
|
120
|
-
exportCookies: (domains: string[]) => Promise<TransferableCookie[]>;
|
|
121
|
-
getBrowserUserAgent: () => Promise<string>;
|
|
122
|
-
log: (...args: any[]) => void;
|
|
123
|
-
createAgentBayClient?: (apiKey: string) => Promise<AgentBayClientLike>;
|
|
124
|
-
connectCdp?: ConnectAgentBayCdp;
|
|
125
|
-
findBrowserRecord?: (selector: string) => {
|
|
126
|
-
record: AgentBayBrowserRecord;
|
|
127
|
-
running: boolean;
|
|
128
|
-
} | null;
|
|
129
|
-
persistBrowserRecord?: (record: AgentBayBrowserRecord) => void;
|
|
130
|
-
resolveApiKey?: () => string;
|
|
131
|
-
}
|
|
132
|
-
interface AgentBayCdpClient {
|
|
133
|
-
sendCommand(method: string, params?: Record<string, any>, timeoutMs?: number): Promise<any>;
|
|
134
|
-
close(): void;
|
|
135
|
-
}
|
|
136
|
-
type ConnectAgentBayCdp = (endpoint: string) => Promise<AgentBayCdpClient>;
|
|
137
|
-
interface AgentBayBrowserSessionInitOptions {
|
|
138
|
-
userAgent?: string;
|
|
139
|
-
connectCdp?: ConnectAgentBayCdp;
|
|
140
|
-
}
|
|
141
|
-
/** Stable managed-browser identity while keeping the cloud provider explicit. */
|
|
142
|
-
export declare function agentBayBrowserId(name: string): string;
|
|
143
|
-
export declare function resolveAgentBayApiKey(): string;
|
|
144
|
-
export declare function resolveAgentBayImageId(value: unknown): string;
|
|
145
|
-
export declare function agentBayContextName(browserId: string): string;
|
|
146
|
-
export declare function normalizeDesktopUserAgent(value: unknown): string;
|
|
147
|
-
export declare function normalizeAgentBayAccessUrl(value: unknown): string | undefined;
|
|
148
|
-
export declare function hasAgentBayBrowser(selector: string): boolean;
|
|
149
|
-
export declare function listAgentBayBrowsers(): AgentBayBrowserSummary[];
|
|
150
|
-
export declare function getAgentBaySession(sessionId: string, dependencies?: Pick<AgentBayBrowserManagerDeps, 'createAgentBayClient' | 'resolveApiKey'>): Promise<AgentBaySessionLike>;
|
|
151
|
-
export declare function getAgentBayAccessUrl(sessionId: string, dependencies?: Pick<AgentBayBrowserManagerDeps, 'createAgentBayClient' | 'resolveApiKey'>): Promise<string>;
|
|
152
|
-
export declare function resolveAgentBayEndpoint(sessionId: string): Promise<string>;
|
|
153
|
-
export declare function keepAgentBaySessionAlive(sessionId: string): Promise<void>;
|
|
154
|
-
export declare function initializeAgentBayBrowserSession(session: Pick<AgentBaySessionLike, 'browser'>, input: Pick<BrowserLaunchParams, 'url'>, cookies: TransferableCookie[], options?: AgentBayBrowserSessionInitOptions): Promise<number>;
|
|
155
|
-
export declare function reuseAgentBayBrowserSession(session: Pick<AgentBaySessionLike, 'browser'>, input: Pick<BrowserLaunchParams, 'url'>, cookies: TransferableCookie[], options?: Pick<AgentBayBrowserSessionInitOptions, 'connectCdp'>): Promise<number>;
|
|
156
|
-
export declare function launchAgentBayBrowser(input: BrowserLaunchParams, deps: AgentBayBrowserManagerDeps): Promise<AgentBayBrowserLaunchResult>;
|
|
157
|
-
export declare function releaseAgentBayBrowserResources(record: AgentBayBrowserRecord, agentBay: AgentBayClientLike, options?: {
|
|
158
|
-
deleteProfile?: boolean;
|
|
159
|
-
persistRecord?: (record: AgentBayBrowserRecord) => void;
|
|
160
|
-
}): Promise<{
|
|
161
|
-
sessionDeleted: boolean;
|
|
162
|
-
contextSynced?: boolean;
|
|
163
|
-
contextDeleted?: boolean;
|
|
164
|
-
}>;
|
|
165
|
-
export declare function closeAgentBayBrowser(selector: string, options?: {
|
|
166
|
-
deleteProfile?: boolean;
|
|
167
|
-
}): Promise<Record<string, any>>;
|
|
168
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type AgentBaySessionLike } from './agentbay-browser.js';
|
|
2
|
-
interface AgentBayPageUploadDependencies {
|
|
3
|
-
getSession?: (sessionId: string) => Promise<AgentBaySessionLike>;
|
|
4
|
-
createTransferId?: () => string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Copies Native Host-local files into the active AgentBay session before CDP selects them.
|
|
8
|
-
* Each file gets an isolated directory so the browser-visible filename stays unchanged.
|
|
9
|
-
* Staged files remain session-scoped because Chromium may read them after the CDP call returns.
|
|
10
|
-
*/
|
|
11
|
-
export declare function stageAgentBayPageUploads(sessionId: string, action: string, data: any, dependencies?: AgentBayPageUploadDependencies): Promise<any>;
|
|
12
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export declare const MIN_AGENTBAY_IDLE_RELEASE_MINUTES = 3;
|
|
2
|
-
export declare const DEFAULT_AGENTBAY_IDLE_RELEASE_MINUTES = 30;
|
|
3
|
-
export declare const DEFAULT_AGENTBAY_MAX_RUNTIME_MINUTES = 120;
|
|
4
|
-
export declare const DEFAULT_AGENTBAY_LIFECYCLE_CHECK_INTERVAL_MS = 60000;
|
|
5
|
-
export interface AgentBayLifecycleConfig {
|
|
6
|
-
idleReleaseTimeout: number;
|
|
7
|
-
maxRuntime: number;
|
|
8
|
-
}
|
|
9
|
-
interface AgentBaySessionWatchdogOptions {
|
|
10
|
-
idleTimeoutMs: number;
|
|
11
|
-
checkIntervalMs?: number;
|
|
12
|
-
now?: () => number;
|
|
13
|
-
keepAlive: () => Promise<void>;
|
|
14
|
-
close: () => Promise<void>;
|
|
15
|
-
log: (...args: unknown[]) => void;
|
|
16
|
-
}
|
|
17
|
-
export declare function resolveAgentBayLifecycleConfig(env?: NodeJS.ProcessEnv): AgentBayLifecycleConfig;
|
|
18
|
-
export declare class AgentBaySessionWatchdog {
|
|
19
|
-
private readonly idleTimeoutMs;
|
|
20
|
-
private readonly checkIntervalMs;
|
|
21
|
-
private readonly now;
|
|
22
|
-
private readonly keepAlive;
|
|
23
|
-
private readonly close;
|
|
24
|
-
private readonly log;
|
|
25
|
-
private activeRequests;
|
|
26
|
-
private lastActivityAt;
|
|
27
|
-
private timer;
|
|
28
|
-
private checking;
|
|
29
|
-
private closing;
|
|
30
|
-
private stopped;
|
|
31
|
-
constructor(options: AgentBaySessionWatchdogOptions);
|
|
32
|
-
start(): void;
|
|
33
|
-
stop(): void;
|
|
34
|
-
beginActivity(): boolean;
|
|
35
|
-
endActivity(): void;
|
|
36
|
-
checkNow(): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
package/dist/analytics.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { BrowserListResult } from '@mearl/browser-core';
|
|
2
|
-
import { type BrowserRecord } from './browser-registry.js';
|
|
3
|
-
import { type ManagedBrowserSummary } from './managed-browser.js';
|
|
4
|
-
import { type AgentBayBrowserSummary } from './agentbay-browser.js';
|
|
5
|
-
type BrowserInventoryResult = Omit<BrowserListResult, 'defaultBrowserId'>;
|
|
6
|
-
export declare function mergeBrowserInventory(connected: BrowserRecord[], managed: Array<ManagedBrowserSummary | AgentBayBrowserSummary>): BrowserInventoryResult;
|
|
7
|
-
export declare function listBrowserInventory(): BrowserInventoryResult;
|
|
8
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser registry — advertises this native-host's connection in a shared,
|
|
3
|
-
* on-disk registry so clients can discover and address multiple browsers at
|
|
4
|
-
* once (multiple Chrome profiles / Chromium-based browsers, each with the
|
|
5
|
-
* extension, each launching its own native-host).
|
|
6
|
-
*
|
|
7
|
-
* Why a registry instead of the old single well-known socket
|
|
8
|
-
* ----------------------------------------------------------
|
|
9
|
-
* Historically every native-host fought over one fixed socket; the last one to
|
|
10
|
-
* start kicked the others off, so at most one browser was reachable and the two
|
|
11
|
-
* flapped on every reconnect. Here each native-host listens on its own unique
|
|
12
|
-
* per-process socket and publishes a record; the client reads the registry and
|
|
13
|
-
* connects to the socket of whichever browser it wants (default: most-recently
|
|
14
|
-
* focused). No contention, N browsers reachable simultaneously.
|
|
15
|
-
*
|
|
16
|
-
* Ownership
|
|
17
|
-
* ---------
|
|
18
|
-
* The record is keyed by the browser's stable installation id, so a browser
|
|
19
|
-
* that reconnects (extension reload → new native-host pid → new socket) simply
|
|
20
|
-
* overwrites its own record. To avoid a briefly-overlapping predecessor wiping
|
|
21
|
-
* the successor's record during a reload, every mutation first checks that the
|
|
22
|
-
* on-disk record still belongs to this process (or is stale) before writing.
|
|
23
|
-
*/
|
|
24
|
-
import { type DaemonRecord } from '@mearl/daemon-core';
|
|
25
|
-
export interface BrowserRecord extends DaemonRecord {
|
|
26
|
-
/** native-host pid — used for liveness pruning. */
|
|
27
|
-
pid: number;
|
|
28
|
-
/** Stable per-installation id reported by the extension (or 'cdp' for daemon mode). */
|
|
29
|
-
browserId: string;
|
|
30
|
-
/** Absolute path of the per-process socket this native-host listens on. */
|
|
31
|
-
socketPath: string;
|
|
32
|
-
/** Human-readable browser name, e.g. "Chrome", "Edge". */
|
|
33
|
-
browserName: string;
|
|
34
|
-
extensionVersion?: string;
|
|
35
|
-
nativeHostVersion: string;
|
|
36
|
-
transport: 'extension' | 'cdp';
|
|
37
|
-
/** Epoch ms when this browser window last gained focus; drives default target selection. */
|
|
38
|
-
lastFocusedAt?: number;
|
|
39
|
-
startedAt: string;
|
|
40
|
-
/** Epoch ms of the last record write; latest-wins tiebreak. */
|
|
41
|
-
updatedAt: number;
|
|
42
|
-
}
|
|
43
|
-
export declare function initBrowserRegistry(deps: {
|
|
44
|
-
log: (...args: any[]) => void;
|
|
45
|
-
}): void;
|
|
46
|
-
/**
|
|
47
|
-
* Publish (or refresh) this native-host's registry record. Called once the
|
|
48
|
-
* browser identity is known — from the extension handshake, or immediately with
|
|
49
|
-
* a synthetic identity in CDP daemon mode.
|
|
50
|
-
*/
|
|
51
|
-
export declare function registerBrowser(info: {
|
|
52
|
-
browserId: string;
|
|
53
|
-
socketPath: string;
|
|
54
|
-
browserName: string;
|
|
55
|
-
nativeHostVersion: string;
|
|
56
|
-
transport: 'extension' | 'cdp';
|
|
57
|
-
extensionVersion?: string;
|
|
58
|
-
/** Initial focus rank. Managed headless browsers use 0 so they do not steal the default target. */
|
|
59
|
-
lastFocusedAt?: number;
|
|
60
|
-
}): void;
|
|
61
|
-
/**
|
|
62
|
-
* Mark this browser as most-recently focused, so it becomes the default target.
|
|
63
|
-
* Focus can change in rapid bursts (fast window switching), so writes are
|
|
64
|
-
* throttled: the first change in an interval writes immediately, further changes
|
|
65
|
-
* schedule a single trailing write rather than one write each.
|
|
66
|
-
*/
|
|
67
|
-
export declare function touchFocus(): void;
|
|
68
|
-
/** Remove our record on shutdown — but only if it is still ours. */
|
|
69
|
-
export declare function unregisterBrowser(): void;
|
|
70
|
-
/**
|
|
71
|
-
* Reap registry records left behind by native-hosts that exited without
|
|
72
|
-
* cleanup (crashes). Live records are kept; a dead record is kept until it is
|
|
73
|
-
* older than STALE_RECORD_TTL_MS so a quickly-reconnecting browser can still
|
|
74
|
-
* inherit its own last-focus time. Meant to run once at startup.
|
|
75
|
-
*/
|
|
76
|
-
export declare function pruneDeadBrowsers(): void;
|
|
77
|
-
/** Live browser connections, ordered by the same focus rank used for default routing. */
|
|
78
|
-
export declare function listRegisteredBrowsers(): BrowserRecord[];
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CDP action registry.
|
|
3
|
-
*
|
|
4
|
-
* Each handler sub-module registers its actions here. The registry replaces
|
|
5
|
-
* the giant switch/case in handleViaCdp with a data-driven lookup.
|
|
6
|
-
*
|
|
7
|
-
* Two session levels:
|
|
8
|
-
* - `browser`: handler receives CdpSession (for tab management, tdbank, etc.)
|
|
9
|
-
* - `page`: handler receives PageSession (for most page-level actions)
|
|
10
|
-
*/
|
|
11
|
-
import type { BrowserCommandAction, ControlSource } from '@mearl/browser-core';
|
|
12
|
-
import type { CdpSession, PageSession } from './cdp-session.js';
|
|
13
|
-
export interface BrowserAction {
|
|
14
|
-
name: BrowserCommandAction;
|
|
15
|
-
session: 'browser';
|
|
16
|
-
handler: (session: CdpSession, data: any, controlSource: ControlSource) => Promise<any>;
|
|
17
|
-
}
|
|
18
|
-
export interface PageAction {
|
|
19
|
-
name: BrowserCommandAction;
|
|
20
|
-
session: 'page';
|
|
21
|
-
handler: (session: PageSession, data: any, controlSource: ControlSource) => Promise<any>;
|
|
22
|
-
}
|
|
23
|
-
export type CdpAction = BrowserAction | PageAction;
|
|
24
|
-
/** Register one or more CDP actions. Called by each handler sub-module. */
|
|
25
|
-
export declare function registerActions(actions: CdpAction[]): void;
|
|
26
|
-
/** Look up a registered action by name. Returns undefined if not found. */
|
|
27
|
-
export declare function getAction(name: string): CdpAction | undefined;
|
|
28
|
-
/** Get all registered action names (useful for diagnostics). */
|
|
29
|
-
export declare function getRegisteredActionNames(): string[];
|
|
30
|
-
/**
|
|
31
|
-
* Dispatch an action by name.
|
|
32
|
-
*
|
|
33
|
-
* Resolves the appropriate session level and calls the handler.
|
|
34
|
-
* Throws if the action is unknown or CDP is not available.
|
|
35
|
-
*/
|
|
36
|
-
export declare function dispatchCdpAction(cdpSession: CdpSession, action: string, data: any, controlSource?: ControlSource): Promise<any>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CDP browser-level handlers: screenshot, selected element, user info.
|
|
3
|
-
*/
|
|
4
|
-
import type { GetUserInfoParams, PageScreenshotParams, PageSelectedElementParams } from '@mearl/browser-core';
|
|
5
|
-
import type { PageSession } from './cdp-session.js';
|
|
6
|
-
export declare function cdpPageScreenshot(session: PageSession, data: PageScreenshotParams): Promise<any>;
|
|
7
|
-
export declare function cdpPageSelectedElement(session: PageSession, _data: PageSelectedElementParams): Promise<any>;
|
|
8
|
-
export declare function cdpGetUserInfo(session: PageSession, data: GetUserInfoParams): Promise<any>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory circular buffers for CDP network requests, console logs, and
|
|
3
|
-
* RUM/tracking events. A single CdpSession subscribes to CDP events and
|
|
4
|
-
* fills these buffers; callers read from them without CDP interaction.
|
|
5
|
-
*/
|
|
6
|
-
import type { MtopRequest, RumEvent, ConsoleLog, RequestBufferAccounting } from '@mearl/browser-core';
|
|
7
|
-
import { type CaptureSequenceState } from '@mearl/browser-core';
|
|
8
|
-
import type { CdpClient, CdpChildSession } from './client.js';
|
|
9
|
-
interface PartialRequest extends MtopRequest {
|
|
10
|
-
id: number;
|
|
11
|
-
requestId: string;
|
|
12
|
-
timestamp: string;
|
|
13
|
-
timestampMs: number;
|
|
14
|
-
method: string;
|
|
15
|
-
url: string;
|
|
16
|
-
apiName: string;
|
|
17
|
-
headers: Array<{
|
|
18
|
-
name: string;
|
|
19
|
-
value: string;
|
|
20
|
-
}>;
|
|
21
|
-
postData: any;
|
|
22
|
-
queryString: Array<{
|
|
23
|
-
name: string;
|
|
24
|
-
value: string;
|
|
25
|
-
}>;
|
|
26
|
-
status: number;
|
|
27
|
-
statusText: string;
|
|
28
|
-
responseHeaders: Array<{
|
|
29
|
-
name: string;
|
|
30
|
-
value: string;
|
|
31
|
-
}>;
|
|
32
|
-
responseBody: any;
|
|
33
|
-
isProxy: boolean;
|
|
34
|
-
proxyRequestUrl: string | null;
|
|
35
|
-
proxyData: any;
|
|
36
|
-
startTs?: number;
|
|
37
|
-
}
|
|
38
|
-
export interface CdpBuffers {
|
|
39
|
-
requests: MtopRequest[];
|
|
40
|
-
logs: ConsoleLog[];
|
|
41
|
-
events: RumEvent[];
|
|
42
|
-
pending: Map<string, PartialRequest>;
|
|
43
|
-
requestCounter: number;
|
|
44
|
-
requestBufferAccounting: RequestBufferAccounting;
|
|
45
|
-
capture: CaptureSequenceState & {
|
|
46
|
-
droppedRequestsThroughSequence: number;
|
|
47
|
-
droppedLogsThroughSequence: number;
|
|
48
|
-
droppedEventsThroughSequence: number;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export declare function createBuffers(tabId?: number): CdpBuffers;
|
|
52
|
-
export declare function setupBufferListeners(client: CdpClient | CdpChildSession, buffers: CdpBuffers): Promise<void>;
|
|
53
|
-
export {};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CDP session manager — maintains browser-level and page-level CDP connections.
|
|
3
|
-
*
|
|
4
|
-
* - Browser client: connected to the browser's top-level WebSocket endpoint.
|
|
5
|
-
* Used for Target.* commands (list/open/close tabs).
|
|
6
|
-
* - Page sessions: per-target connections used for page interaction, screenshots,
|
|
7
|
-
* and buffered network/log/event collection.
|
|
8
|
-
*/
|
|
9
|
-
import { CdpClient, CdpChildSession } from './client.js';
|
|
10
|
-
import { type CdpBuffers } from './buffers.js';
|
|
11
|
-
export interface PageSession {
|
|
12
|
-
tabId: number;
|
|
13
|
-
client: CdpClient | CdpChildSession;
|
|
14
|
-
buffers: CdpBuffers;
|
|
15
|
-
targetId: string;
|
|
16
|
-
url: string;
|
|
17
|
-
emulation?: {
|
|
18
|
-
mobile: boolean;
|
|
19
|
-
touch: boolean;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export interface CdpSessionOptions {
|
|
23
|
-
port?: number;
|
|
24
|
-
userDataDir?: string;
|
|
25
|
-
endpointUrl?: string;
|
|
26
|
-
endpointResolver?: () => Promise<string>;
|
|
27
|
-
}
|
|
28
|
-
export declare class CdpSession {
|
|
29
|
-
readonly port: number;
|
|
30
|
-
readonly userDataDir?: string;
|
|
31
|
-
private readonly endpointUrl?;
|
|
32
|
-
private readonly endpointResolver?;
|
|
33
|
-
private browserClient;
|
|
34
|
-
private pageSessions;
|
|
35
|
-
/** Virtual tabId counter → CDP targetId */
|
|
36
|
-
private tabIdMap;
|
|
37
|
-
private nextTabId;
|
|
38
|
-
constructor(options?: number | CdpSessionOptions);
|
|
39
|
-
getBrowserClient(): Promise<CdpClient>;
|
|
40
|
-
/**
|
|
41
|
-
* Get (or create) a page session.
|
|
42
|
-
*
|
|
43
|
-
* @param virtualTabId Numeric tabId returned by `tab_open` (optional).
|
|
44
|
-
* If omitted, connects to the first available page target.
|
|
45
|
-
*/
|
|
46
|
-
getPageSession(virtualTabId?: number): Promise<PageSession>;
|
|
47
|
-
/** Register a newly opened target as a virtual tabId and return the numeric ID. */
|
|
48
|
-
registerTarget(targetId: string): Promise<number>;
|
|
49
|
-
/** Return the existing virtual tabId for a target, registering it when first discovered. */
|
|
50
|
-
ensureTargetRegistered(targetId: string): Promise<number>;
|
|
51
|
-
private createPageSession;
|
|
52
|
-
private findTargetById;
|
|
53
|
-
private findDefaultPageTarget;
|
|
54
|
-
/** Effective port: from DevToolsActivePort file if present, else this.port */
|
|
55
|
-
private effectivePort;
|
|
56
|
-
/**
|
|
57
|
-
* Resolve the browser-level WebSocket URL.
|
|
58
|
-
* Priority: DevToolsActivePort file → HTTP /json/version
|
|
59
|
-
*/
|
|
60
|
-
private resolveBrowserWsUrl;
|
|
61
|
-
/**
|
|
62
|
-
* Build a page-level WebSocket URL from a target ID.
|
|
63
|
-
* Used when HTTP /json is unavailable.
|
|
64
|
-
*/
|
|
65
|
-
private pageWsUrl;
|
|
66
|
-
private isRemote;
|
|
67
|
-
private findTargetByIdViaCdp;
|
|
68
|
-
private findDefaultPageTargetViaCdp;
|
|
69
|
-
private fetchVersionInfo;
|
|
70
|
-
hasActiveConnections(): boolean;
|
|
71
|
-
listOpenPageSessions(): PageSession[];
|
|
72
|
-
listRegisteredTabIds(targetIds?: ReadonlySet<string>): number[];
|
|
73
|
-
close(): void;
|
|
74
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared utilities for CDP backend handlers.
|
|
3
|
-
*
|
|
4
|
-
* Contains: HTTP helper (nodeFetch), cookie utilities, page-load waiters,
|
|
5
|
-
* viewport helpers, and serialized function sources for page injection.
|
|
6
|
-
*/
|
|
7
|
-
import { type PageClickPointerType, type PageDragPoint, type PageDragPointerType } from '@mearl/browser-core';
|
|
8
|
-
import type { PageSession } from './cdp-session.js';
|
|
9
|
-
export declare const TYPE_INTO_ELEMENT_SRC: string;
|
|
10
|
-
export declare const CLICK_ELEMENT_VIA_JS_SRC: string;
|
|
11
|
-
export declare const GET_CLICK_COORDS_FROM_NODE_SRC: string;
|
|
12
|
-
export interface CdpViewportMetrics {
|
|
13
|
-
cssLayoutViewport?: {
|
|
14
|
-
clientWidth?: number;
|
|
15
|
-
clientHeight?: number;
|
|
16
|
-
};
|
|
17
|
-
cssVisualViewport?: {
|
|
18
|
-
clientWidth?: number;
|
|
19
|
-
clientHeight?: number;
|
|
20
|
-
scale?: number;
|
|
21
|
-
};
|
|
22
|
-
layoutViewport?: {
|
|
23
|
-
clientWidth?: number;
|
|
24
|
-
clientHeight?: number;
|
|
25
|
-
};
|
|
26
|
-
visualViewport?: {
|
|
27
|
-
clientWidth?: number;
|
|
28
|
-
clientHeight?: number;
|
|
29
|
-
scale?: number;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export declare function nodeFetch(urlStr: string, options?: {
|
|
33
|
-
method?: string;
|
|
34
|
-
headers?: Record<string, string>;
|
|
35
|
-
body?: string | Uint8Array;
|
|
36
|
-
timeoutMs?: number;
|
|
37
|
-
}): Promise<{
|
|
38
|
-
status: number;
|
|
39
|
-
statusText: string;
|
|
40
|
-
headers: Record<string, string>;
|
|
41
|
-
body: string;
|
|
42
|
-
bodyBuffer: Buffer;
|
|
43
|
-
}>;
|
|
44
|
-
export declare function getCookiesForUrl(session: PageSession, targetUrl: string): Promise<Map<string, string>>;
|
|
45
|
-
export declare function decodeTracknick(raw: string): string;
|
|
46
|
-
export declare function buildMultipartFormBody(fields: Record<string, string>): {
|
|
47
|
-
contentType: string;
|
|
48
|
-
body: string;
|
|
49
|
-
};
|
|
50
|
-
export declare function waitForPageLoad(session: PageSession, timeoutMs: number): Promise<void>;
|
|
51
|
-
export declare function getPageViewportSize(session: PageSession): Promise<{
|
|
52
|
-
width: number;
|
|
53
|
-
height: number;
|
|
54
|
-
} | null>;
|
|
55
|
-
export declare function getCdpInputViewportSize(session: PageSession): Promise<{
|
|
56
|
-
width: number;
|
|
57
|
-
height: number;
|
|
58
|
-
} | null>;
|
|
59
|
-
export declare function toCdpInputPoint(session: PageSession, x: number, y: number): Promise<{
|
|
60
|
-
x: number;
|
|
61
|
-
y: number;
|
|
62
|
-
}>;
|
|
63
|
-
export declare function dispatchCdpClick(session: PageSession, x: number, y: number, pointerType: PageClickPointerType): Promise<void>;
|
|
64
|
-
export declare function dispatchCdpDrag(session: PageSession, from: PageDragPoint, to: PageDragPoint, pointerType: PageDragPointerType, durationMs: number): Promise<{
|
|
65
|
-
steps: number;
|
|
66
|
-
}>;
|
|
67
|
-
export declare function resolveBackendNodeObjectId(session: PageSession, backendNodeId: number): Promise<string>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/** WebSocket CDP client shared by local and remote browser sessions. */
|
|
2
|
-
type EventCallback = (params: any) => void;
|
|
3
|
-
export declare class CdpChildSession {
|
|
4
|
-
private readonly parent;
|
|
5
|
-
readonly sessionId: string;
|
|
6
|
-
constructor(parent: CdpClient, sessionId: string);
|
|
7
|
-
sendCommand(method: string, params?: Record<string, any>, timeoutMs?: number): Promise<any>;
|
|
8
|
-
on(method: string, callback: EventCallback): () => void;
|
|
9
|
-
get closed(): boolean;
|
|
10
|
-
close(): void;
|
|
11
|
-
}
|
|
12
|
-
export declare class CdpClient {
|
|
13
|
-
private readonly socket;
|
|
14
|
-
private nextId;
|
|
15
|
-
private pending;
|
|
16
|
-
private eventHandlers;
|
|
17
|
-
private sessionEventHandlers;
|
|
18
|
-
private _closed;
|
|
19
|
-
private constructor();
|
|
20
|
-
static connect(wsUrl: string): Promise<CdpClient>;
|
|
21
|
-
createChildSession(sessionId: string): CdpChildSession;
|
|
22
|
-
sendCommandInSession(sessionId: string, method: string, params?: Record<string, any>, timeoutMs?: number): Promise<any>;
|
|
23
|
-
onSession(sessionId: string, method: string, callback: EventCallback): () => void;
|
|
24
|
-
sendCommand(method: string, params?: Record<string, any>, timeoutMs?: number): Promise<any>;
|
|
25
|
-
on(method: string, callback: EventCallback): () => void;
|
|
26
|
-
close(): void;
|
|
27
|
-
get closed(): boolean;
|
|
28
|
-
private sendRequest;
|
|
29
|
-
private consumeMessage;
|
|
30
|
-
private handleMessage;
|
|
31
|
-
private handleClosed;
|
|
32
|
-
private rejectPending;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CDP composite action handlers.
|
|
3
|
-
*
|
|
4
|
-
* Provides `run_actions` — sequential batch execution of multiple actions
|
|
5
|
-
* within a single request, sharing the same CDP session — and the observed
|
|
6
|
-
* page-action wrapper that gives page interaction actions their default
|
|
7
|
-
* built-in observation.
|
|
8
|
-
*/
|
|
9
|
-
import type { CdpSession } from './cdp-session.js';
|
|
10
|
-
import { type ControlSource, type PageActAction, type RunActionsParams } from '@mearl/browser-core';
|
|
11
|
-
export declare function cdpRunActions(session: CdpSession, data: RunActionsParams, controlSource?: ControlSource): Promise<any>;
|
|
12
|
-
/**
|
|
13
|
-
* Runs a page interaction action with built-in observation. Diagnostics are
|
|
14
|
-
* collected only when the caller requests them.
|
|
15
|
-
* `run_actions` stays lightweight and never enters this wrapper.
|
|
16
|
-
*/
|
|
17
|
-
export declare function cdpObservedPageAction(session: CdpSession, action: PageActAction, data: any, controlSource?: ControlSource): Promise<any>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CDP 模式的受控页面视觉标识。
|
|
3
|
-
*
|
|
4
|
-
* 与扩展模式共享同一套 Mearl favicon 变体,本地操作显示绿色圆点角标,云端操作
|
|
5
|
-
* 显示紫色云朵角标。图标通过 data URL 内联到新文档脚本,不依赖扩展资源或网络。
|
|
6
|
-
*
|
|
7
|
-
* 注入通过 Page.addScriptToEvaluateOnNewDocument + runImmediately 完成:脚本在
|
|
8
|
-
* PageSession 存续期内跨导航生效;控制来源变化时替换脚本并立即更新当前文档。
|
|
9
|
-
*/
|
|
10
|
-
import { type ControlSource } from '@mearl/browser-core';
|
|
11
|
-
import type { PageSession } from './cdp-session.js';
|
|
12
|
-
/**
|
|
13
|
-
* 确保受控标识已注入到该 page session。相同来源幂等;来源变化时替换跨导航脚本,
|
|
14
|
-
* runImmediately 同步更新当前文档。任何异常都不阻断 agent 动作本身。
|
|
15
|
-
*/
|
|
16
|
-
export declare function ensureControlledIndicator(session: PageSession, controlSource?: ControlSource): Promise<void>;
|
|
17
|
-
/** browser_release 使用:停止跨导航注入并恢复当前文档的 favicon。 */
|
|
18
|
-
export declare function releaseControlledIndicator(session: PageSession): Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** CDP handler for changing one named cookie in the current page scope. */
|
|
2
|
-
import { type GetCookieParams, type SetCookieParams } from '@mearl/browser-core';
|
|
3
|
-
import type { PageSession } from './cdp-session.js';
|
|
4
|
-
export declare function cdpSetCookie(session: PageSession, data: SetCookieParams): Promise<any>;
|
|
5
|
-
export declare function cdpGetCookie(session: PageSession, data: GetCookieParams): Promise<any>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/** Cookie export/import helpers for copying selected domains between CDP browsers. */
|
|
2
|
-
import type { CdpSession } from './cdp-session.js';
|
|
3
|
-
export interface TransferableCookie {
|
|
4
|
-
name: string;
|
|
5
|
-
value: string;
|
|
6
|
-
domain: string;
|
|
7
|
-
path: string;
|
|
8
|
-
secure?: boolean;
|
|
9
|
-
httpOnly?: boolean;
|
|
10
|
-
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
11
|
-
expires?: number;
|
|
12
|
-
priority?: 'Low' | 'Medium' | 'High';
|
|
13
|
-
sameParty?: boolean;
|
|
14
|
-
sourceScheme?: 'Unset' | 'NonSecure' | 'Secure';
|
|
15
|
-
sourcePort?: number;
|
|
16
|
-
partitionKey?: {
|
|
17
|
-
topLevelSite: string;
|
|
18
|
-
hasCrossSiteAncestor?: boolean;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
interface CookieCommandClient {
|
|
22
|
-
sendCommand(method: string, params?: Record<string, any>, timeoutMs?: number): Promise<any>;
|
|
23
|
-
}
|
|
24
|
-
export declare function normalizeCookieDomain(input: string): string;
|
|
25
|
-
export declare function normalizeCookieDomains(inputs: unknown): string[];
|
|
26
|
-
export declare function cookieMatchesDomain(cookieDomain: string, requestedDomain: string): boolean;
|
|
27
|
-
export declare function cdpExportCookies(session: CdpSession, domains: string[]): Promise<TransferableCookie[]>;
|
|
28
|
-
export declare function cdpImportCookies(session: CdpSession, cookies: TransferableCookie[]): Promise<number>;
|
|
29
|
-
export declare function cdpImportCookiesWithClient(browser: CookieCommandClient, cookies: TransferableCookie[]): Promise<number>;
|
|
30
|
-
export {};
|