@mearl/native-host 2.0.2 → 2.2.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 (33) hide show
  1. package/README.md +1 -1
  2. package/dist/agent/codex-provider.d.ts +5 -1
  3. package/dist/agent/executable-resolver.d.ts +34 -0
  4. package/dist/agent/manager.d.ts +7 -13
  5. package/dist/agent/provider.d.ts +4 -11
  6. package/dist/agent/qoder-provider.d.ts +3 -0
  7. package/dist/agent/skill-manager.d.ts +2 -5
  8. package/dist/analytics.d.ts +2 -0
  9. package/dist/browser-inventory.d.ts +2 -28
  10. package/dist/cdp-backend/action-registry.d.ts +6 -5
  11. package/dist/cdp-backend/browser-handlers.d.ts +4 -3
  12. package/dist/cdp-backend/buffers.d.ts +2 -1
  13. package/dist/cdp-backend/cdp-session.d.ts +3 -0
  14. package/dist/cdp-backend/composite-handlers.d.ts +3 -3
  15. package/dist/cdp-backend/controlled-indicator.d.ts +10 -9
  16. package/dist/cdp-backend/cookie-handlers.d.ts +5 -0
  17. package/dist/cdp-backend/handlers.d.ts +2 -0
  18. package/dist/cdp-backend/http-handlers.d.ts +4 -3
  19. package/dist/cdp-backend/interaction-handlers.d.ts +11 -10
  20. package/dist/cdp-backend/mock-handlers.d.ts +5 -2
  21. package/dist/cdp-backend/recording-handlers.d.ts +5 -2
  22. package/dist/cdp-backend/release-control.d.ts +13 -0
  23. package/dist/cdp-backend/request-handlers.d.ts +4 -3
  24. package/dist/cdp-backend/snapshot-handlers.d.ts +3 -2
  25. package/dist/cdp-backend/tab-handlers.d.ts +3 -2
  26. package/dist/cdp-backend/tdbank-handlers.d.ts +3 -2
  27. package/dist/cdp-backend/timezone-handlers.d.ts +2 -1
  28. package/dist/cloud-connector.d.ts +9 -4
  29. package/dist/index.js +4038 -3096
  30. package/dist/internal-extension-actions.d.ts +2 -1
  31. package/dist/managed-browser.d.ts +4 -17
  32. package/dist/version.d.ts +1 -0
  33. package/package.json +3 -3
package/README.md CHANGED
@@ -85,7 +85,7 @@ qodercli
85
85
  MEARL_QODER_PATH=/absolute/path/to/qodercli
86
86
  ```
87
87
 
88
- 侧边栏中未选择本地目录时,Codex 对话使用只读沙箱且不允许提权,Qoder 对话通过首条提示词约束为只读模式;选择后才使用该目录作为可写工作区。`MEARL_AGENT_CWD` 仅用于 Codex 只读对话的默认浏览目录,不会开启写权限;Qoder 未选目录时从用户主目录开始浏览。Agent 接入由统一 Provider 接口承载,后续可新增 Claude 等实现而无需修改扩展与 native-host 之间的 Chat 协议。只安装 ChatGPT 等桌面聊天客户端不能替代 Provider CLI;侧边栏会在 CLI 缺失时展示安装与登录指引。
88
+ 侧边栏 Agent 不使用只读或工作区沙箱限制,文件、命令和网络操作由 Provider 的审批机制控制。用户选择的本地目录只作为对话的参考上下文和相对路径起点,不限制 Agent 可访问的范围;未选择时从用户主目录开始,Codex 可通过 `MEARL_AGENT_CWD` 覆盖默认起点。Agent 接入由统一 Provider 接口承载,后续可新增 Claude 等实现而无需修改扩展与 native-host 之间的 Chat 协议。只安装 ChatGPT 等桌面聊天客户端不能替代 Provider CLI;侧边栏会在 CLI 缺失时展示安装与登录指引。
89
89
 
90
90
  ## 构建
91
91
 
@@ -8,6 +8,7 @@ export declare function externalOpenCommand(url: string, platform?: NodeJS.Platf
8
8
  export declare class CodexAgentProvider implements AgentProvider {
9
9
  private readonly log;
10
10
  private readonly clientVersion;
11
+ private readonly mearlSocketPath?;
11
12
  readonly id = "codex";
12
13
  private process;
13
14
  private initialized;
@@ -17,8 +18,10 @@ export declare class CodexAgentProvider implements AgentProvider {
17
18
  private listeners;
18
19
  private knownThreadIds;
19
20
  private sessionModels;
20
- constructor(log: (...args: any[]) => void, clientVersion: string);
21
+ private readonly executableResolver;
22
+ constructor(log: (...args: any[]) => void, clientVersion: string, mearlSocketPath?: string | undefined);
21
23
  getDescriptor(): Promise<AgentChatProviderDescriptor>;
24
+ prepare(): Promise<void>;
22
25
  onEvent(listener: (event: AgentProviderEvent) => void): () => void;
23
26
  listSessions(options: AgentProviderListSessionsOptions): Promise<AgentProviderListSessionsResult>;
24
27
  listSkills(cwd?: string): Promise<AgentInstalledSkill[]>;
@@ -44,4 +47,5 @@ export declare class CodexAgentProvider implements AgentProvider {
44
47
  private extractThreadId;
45
48
  private probeExecutable;
46
49
  private resolveExecutable;
50
+ private resolveExecutableCandidates;
47
51
  }
@@ -0,0 +1,34 @@
1
+ export type AgentExecutableResolution = {
2
+ executable: string;
3
+ error: null;
4
+ } | {
5
+ executable: null;
6
+ error: string;
7
+ };
8
+ interface AgentExecutableResolverOptions {
9
+ candidates: () => string[];
10
+ probe: (executable: string) => Promise<string | null>;
11
+ notFoundError: string;
12
+ unusableError: string;
13
+ onFailure?: (executable: string, error: string) => void;
14
+ }
15
+ interface AgentExecutableProbeOptions {
16
+ args: string[];
17
+ timeoutMs: number;
18
+ timeoutError: string;
19
+ startError: (error: Error) => string;
20
+ exitError: (code: number | null) => string;
21
+ }
22
+ export declare class AgentExecutableResolver {
23
+ private readonly options;
24
+ private resolvedExecutable;
25
+ private resolutionPromise;
26
+ private generation;
27
+ constructor(options: AgentExecutableResolverOptions);
28
+ resolve(): Promise<AgentExecutableResolution>;
29
+ reset(): void;
30
+ private probeCandidates;
31
+ }
32
+ export declare function executableFileCandidates(candidates: Array<string | null | undefined>): string[];
33
+ export declare function probeAgentExecutable(executable: string, options: AgentExecutableProbeOptions): Promise<string | null>;
34
+ export {};
@@ -1,4 +1,4 @@
1
- import type { AgentChatEvent, AgentChatCloseOptions, AgentChatEventsOptions, AgentChatEventsResult, AgentChatInterruptOptions, AgentChatListSessionsOptions, AgentChatListSessionsResult, AgentChatOpenOptions, AgentChatRefreshResult, AgentChatRespondOptions, AgentChatSendOptions, AgentChatSession, AgentChatStartOptions, AgentChatStatus, AgentInstalledSkill, AgentSkillReadResult } from '@mearl/browser-core';
1
+ import type { AgentChatEvent, AgentChatEventsOptions, AgentChatEventsResult, AgentChatListSessionsOptions, AgentChatListSessionsResult, AgentChatPrepareOptions, AgentChatRefreshResult, AgentChatRespondOptions, AgentChatSendOptions, AgentChatSession, AgentChatSessionTarget, AgentChatStartOptions, AgentChatStatus, AgentInstalledSkill, AgentSkillInstalledListOptions, AgentSkillReadOptions, AgentSkillReadResult } from '@mearl/browser-core';
2
2
  import type { AgentProvider } from './provider.js';
3
3
  export declare class AgentChatManager {
4
4
  private readonly emit;
@@ -14,23 +14,17 @@ export declare class AgentChatManager {
14
14
  private readonly unsubscribe;
15
15
  constructor(providers: AgentProvider[], emit: (event: AgentChatEvent) => void);
16
16
  getStatus(): Promise<AgentChatStatus>;
17
- listSkills(options: {
18
- providerId?: unknown;
19
- cwd?: unknown;
20
- }): Promise<AgentInstalledSkill[]>;
21
- readSkill(options: {
22
- providerId?: unknown;
23
- path?: unknown;
24
- cwd?: unknown;
25
- }): Promise<AgentSkillReadResult>;
17
+ prepare(options: AgentChatPrepareOptions): Promise<void>;
18
+ listSkills(options: AgentSkillInstalledListOptions): Promise<AgentInstalledSkill[]>;
19
+ readSkill(options: AgentSkillReadOptions): Promise<AgentSkillReadResult>;
26
20
  listSessions(options: AgentChatListSessionsOptions): Promise<AgentChatListSessionsResult>;
27
21
  startSession(options: AgentChatStartOptions): Promise<AgentChatSession>;
28
22
  sendMessage(options: AgentChatSendOptions): Promise<{
29
23
  turnId: string;
30
24
  }>;
31
- interrupt(options: AgentChatInterruptOptions): Promise<void>;
32
- openSession(options: AgentChatOpenOptions): Promise<void>;
33
- closeSession(options: AgentChatCloseOptions): Promise<void>;
25
+ interrupt(options: AgentChatSessionTarget): Promise<void>;
26
+ openSession(options: AgentChatSessionTarget): Promise<void>;
27
+ closeSession(options: AgentChatSessionTarget): Promise<void>;
34
28
  getEvents(options: AgentChatEventsOptions): AgentChatEventsResult;
35
29
  refreshSession(options: AgentChatEventsOptions): Promise<AgentChatRefreshResult>;
36
30
  respondToRequest(options: AgentChatRespondOptions): void;
@@ -1,4 +1,4 @@
1
- import type { AgentChatEventKind, AgentChatImageInput, AgentChatModelInfo, AgentChatProviderDescriptor, AgentInstalledSkill } from '@mearl/browser-core';
1
+ import type { AgentChatEventKind, AgentChatImageInput, AgentChatListSessionsOptions, AgentChatModelInfo, AgentChatProviderDescriptor, AgentChatSessionSummary, AgentInstalledSkill } from '@mearl/browser-core';
2
2
  export interface AgentProviderEvent {
3
3
  providerSessionId?: string;
4
4
  kind: AgentChatEventKind;
@@ -12,16 +12,8 @@ export interface AgentProviderSessionOptions {
12
12
  developerInstructions?: string;
13
13
  ephemeral?: boolean;
14
14
  }
15
- export interface AgentProviderSessionSummary {
16
- providerSessionId: string;
17
- title?: string;
18
- cwd?: string;
19
- updatedAt?: number;
20
- ephemeral?: boolean;
21
- }
22
- export interface AgentProviderListSessionsOptions {
23
- cwd?: string;
24
- cursor?: string;
15
+ export type AgentProviderSessionSummary = Omit<AgentChatSessionSummary, 'providerId'>;
16
+ export interface AgentProviderListSessionsOptions extends Omit<AgentChatListSessionsOptions, 'providerId' | 'limit'> {
25
17
  limit: number;
26
18
  }
27
19
  export interface AgentProviderListSessionsResult {
@@ -36,6 +28,7 @@ export interface AgentProviderResumeResult {
36
28
  export interface AgentProvider {
37
29
  readonly id: string;
38
30
  getDescriptor(): Promise<AgentChatProviderDescriptor>;
31
+ prepare(): Promise<void>;
39
32
  onEvent(listener: (event: AgentProviderEvent) => void): () => void;
40
33
  listSessions?(options: AgentProviderListSessionsOptions): Promise<AgentProviderListSessionsResult>;
41
34
  listSkills?(cwd?: string): Promise<AgentInstalledSkill[]>;
@@ -18,8 +18,10 @@ export declare class QoderAgentProvider implements AgentProvider {
18
18
  private pendingPermissions;
19
19
  private historyCaptures;
20
20
  private nextTurnId;
21
+ private readonly executableResolver;
21
22
  constructor(log: (...args: any[]) => void, clientVersion: string);
22
23
  getDescriptor(): Promise<AgentChatProviderDescriptor>;
24
+ prepare(): Promise<void>;
23
25
  onEvent(listener: (event: AgentProviderEvent) => void): () => void;
24
26
  listSessions(options: AgentProviderListSessionsOptions): Promise<AgentProviderListSessionsResult>;
25
27
  listSkills(cwd?: string): Promise<AgentInstalledSkill[]>;
@@ -48,5 +50,6 @@ export declare class QoderAgentProvider implements AgentProvider {
48
50
  private probeExecutable;
49
51
  private runSkillsList;
50
52
  private resolveExecutable;
53
+ private resolveExecutableCandidates;
51
54
  private emit;
52
55
  }
@@ -1,4 +1,4 @@
1
- import type { AgentSkillCheckUpdatesResult, AgentSkillCliStatus, AgentSkillInstallOptions, AgentSkillMutationOptions, AgentSkillMutationResult, AgentSkillScope, AgentSkillUpdate } from '@mearl/browser-core';
1
+ import type { AgentSkillCheckUpdatesResult, AgentSkillCheckUpdatesOptions, AgentSkillCliStatus, AgentSkillInstallOptions, AgentSkillMutationOptions, AgentSkillMutationResult, AgentSkillScope, AgentSkillUpdate } from '@mearl/browser-core';
2
2
  interface SkillCliOutput {
3
3
  stdout: string;
4
4
  stderr: string;
@@ -17,10 +17,7 @@ export declare class AgentSkillManager {
17
17
  constructor(options?: AgentSkillManagerOptions);
18
18
  getStatus(): Promise<AgentSkillCliStatus>;
19
19
  install(data: AgentSkillInstallOptions): Promise<AgentSkillMutationResult>;
20
- checkUpdates(data: {
21
- providerId?: unknown;
22
- cwd?: unknown;
23
- }): Promise<AgentSkillCheckUpdatesResult>;
20
+ checkUpdates(data: AgentSkillCheckUpdatesOptions): Promise<AgentSkillCheckUpdatesResult>;
24
21
  update(data: AgentSkillMutationOptions): Promise<AgentSkillMutationResult>;
25
22
  uninstall(data: AgentSkillMutationOptions): Promise<AgentSkillMutationResult>;
26
23
  private mutationContext;
@@ -1 +1,3 @@
1
+ export declare function setAnalyticsClientId(value: unknown): boolean;
2
+ export declare function classifyAnalyticsError(error: unknown): string;
1
3
  export declare function trackAction(action: string, params?: Record<string, string | number | boolean>): void;
@@ -1,33 +1,7 @@
1
+ import type { BrowserListResult } from '@mearl/browser-core';
1
2
  import { type BrowserRecord } from './browser-registry.js';
2
3
  import { type ManagedBrowserSummary } from './managed-browser.js';
3
- export type BrowserStatus = 'connected' | 'running_disconnected' | 'stopped';
4
- interface BrowserInventoryBase {
5
- browserId: string;
6
- name: string;
7
- status: BrowserStatus;
8
- extensionVersion?: string;
9
- nativeHostVersion?: string;
10
- transport?: 'extension' | 'cdp';
11
- }
12
- export interface RegularBrowserInventoryItem extends BrowserInventoryBase {
13
- type: 'regular';
14
- status: 'connected';
15
- }
16
- export interface ManagedBrowserInventoryItem extends BrowserInventoryBase {
17
- type: 'managed';
18
- headless: boolean;
19
- persistent: boolean;
20
- cdpPort: number;
21
- createdAt: string;
22
- account?: ManagedBrowserSummary['account'];
23
- copiedCookies?: ManagedBrowserSummary['copiedCookies'];
24
- }
25
- export type BrowserInventoryItem = RegularBrowserInventoryItem | ManagedBrowserInventoryItem;
26
- export interface BrowserInventoryResult {
27
- count: number;
28
- connectedCount: number;
29
- browsers: BrowserInventoryItem[];
30
- }
4
+ type BrowserInventoryResult = Omit<BrowserListResult, 'defaultBrowserId'>;
31
5
  export declare function mergeBrowserInventory(connected: BrowserRecord[], managed: ManagedBrowserSummary[]): BrowserInventoryResult;
32
6
  export declare function listBrowserInventory(): BrowserInventoryResult;
33
7
  export {};
@@ -8,16 +8,17 @@
8
8
  * - `browser`: handler receives CdpSession (for tab management, tdbank, etc.)
9
9
  * - `page`: handler receives PageSession (for most page-level actions)
10
10
  */
11
+ import type { BrowserCommandAction, ControlSource } from '@mearl/browser-core';
11
12
  import type { CdpSession, PageSession } from './cdp-session.js';
12
13
  export interface BrowserAction {
13
- name: string;
14
+ name: BrowserCommandAction;
14
15
  session: 'browser';
15
- handler: (session: CdpSession, data: any) => Promise<any>;
16
+ handler: (session: CdpSession, data: any, controlSource: ControlSource) => Promise<any>;
16
17
  }
17
18
  export interface PageAction {
18
- name: string;
19
+ name: BrowserCommandAction;
19
20
  session: 'page';
20
- handler: (session: PageSession, data: any) => Promise<any>;
21
+ handler: (session: PageSession, data: any, controlSource: ControlSource) => Promise<any>;
21
22
  }
22
23
  export type CdpAction = BrowserAction | PageAction;
23
24
  /** Register one or more CDP actions. Called by each handler sub-module. */
@@ -32,4 +33,4 @@ export declare function getRegisteredActionNames(): string[];
32
33
  * Resolves the appropriate session level and calls the handler.
33
34
  * Throws if the action is unknown or CDP is not available.
34
35
  */
35
- export declare function dispatchCdpAction(cdpSession: CdpSession, action: string, data: any): Promise<any>;
36
+ export declare function dispatchCdpAction(cdpSession: CdpSession, action: string, data: any, controlSource?: ControlSource): Promise<any>;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * CDP browser-level handlers: screenshot, selected element, user info.
3
3
  */
4
+ import type { GetUserInfoParams, PageScreenshotParams, PageSelectedElementParams } from '@mearl/browser-core';
4
5
  import type { PageSession } from './cdp-session.js';
5
- export declare function cdpPageScreenshot(session: PageSession, data: any): Promise<any>;
6
- export declare function cdpPageSelectedElement(session: PageSession, _data: any): Promise<any>;
7
- export declare function cdpGetUserInfo(session: PageSession, data: any): Promise<any>;
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>;
@@ -3,7 +3,7 @@
3
3
  * RUM/tracking events. A single CdpSession subscribes to CDP events and
4
4
  * fills these buffers; callers read from them without CDP interaction.
5
5
  */
6
- import type { MtopRequest, RumEvent, ConsoleLog } from '@mearl/browser-core';
6
+ import type { MtopRequest, RumEvent, ConsoleLog, RequestBufferAccounting } from '@mearl/browser-core';
7
7
  import type { CdpClient, CdpChildSession } from './client.js';
8
8
  interface PartialRequest {
9
9
  id: number;
@@ -40,6 +40,7 @@ export interface CdpBuffers {
40
40
  events: RumEvent[];
41
41
  pending: Map<string, PartialRequest>;
42
42
  requestCounter: number;
43
+ requestBufferAccounting: RequestBufferAccounting;
43
44
  }
44
45
  export declare function createBuffers(): CdpBuffers;
45
46
  export declare function setupBufferListeners(client: CdpClient | CdpChildSession, buffers: CdpBuffers): void;
@@ -60,5 +60,8 @@ export declare class CdpSession {
60
60
  private findTargetByIdViaCdp;
61
61
  private findDefaultPageTargetViaCdp;
62
62
  private fetchVersionInfo;
63
+ hasActiveConnections(): boolean;
64
+ listOpenPageSessions(): PageSession[];
65
+ listRegisteredTabIds(targetIds?: ReadonlySet<string>): number[];
63
66
  close(): void;
64
67
  }
@@ -7,8 +7,8 @@
7
7
  * built-in observation.
8
8
  */
9
9
  import type { CdpSession } from './cdp-session.js';
10
- import { type PageActAction } from '@mearl/browser-core';
11
- export declare function cdpRunActions(session: CdpSession, data: any): Promise<any>;
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
12
  /**
13
13
  * Runs a page interaction action with built-in observation: executes the raw
14
14
  * handler inside `runPageAct` and reports resulting page changes / navigation
@@ -16,4 +16,4 @@ export declare function cdpRunActions(session: CdpSession, data: any): Promise<a
16
16
  * dispatches the raw handler directly. `run_actions` steps never go through
17
17
  * this wrapper — they use dispatchCdpAction and stay lightweight.
18
18
  */
19
- export declare function cdpObservedPageAction(session: CdpSession, action: PageActAction, data: any): Promise<any>;
19
+ export declare function cdpObservedPageAction(session: CdpSession, action: PageActAction, data: any, controlSource?: ControlSource): Promise<any>;
@@ -1,17 +1,18 @@
1
1
  /**
2
2
  * CDP 模式的受控页面视觉标识。
3
3
  *
4
- * 与扩展模式的 favicon 替换保持一致:agent 操作过的页面把 favicon 换成 Mearl
5
- * 图标。CDP 模式拿不到扩展资源,图标以 data URL 内联在注入脚本里,不依赖任何
6
- * 网络请求。
4
+ * 与扩展模式共享同一套 Mearl favicon 变体,本地操作显示绿色圆点角标,云端操作
5
+ * 显示紫色云朵角标。图标通过 data URL 内联到新文档脚本,不依赖扩展资源或网络。
7
6
  *
8
- * 注入通过 Page.addScriptToEvaluateOnNewDocument + runImmediately 完成:每个
9
- * PageSession 只注册一次,注册的脚本在 session 存续期内跨导航自动生效;
10
- * session 断开重建后由下一次动作重新注册。
7
+ * 注入通过 Page.addScriptToEvaluateOnNewDocument + runImmediately 完成:脚本在
8
+ * PageSession 存续期内跨导航生效;控制来源变化时替换脚本并立即更新当前文档。
11
9
  */
10
+ import { type ControlSource } from '@mearl/browser-core';
12
11
  import type { PageSession } from './cdp-session.js';
13
12
  /**
14
- * 确保受控标识已注入到该 page session。幂等且 best-effort:
15
- * 失败时撤销标记,下一次动作重试;任何异常都不阻断 agent 动作本身。
13
+ * 确保受控标识已注入到该 page session。相同来源幂等;来源变化时替换跨导航脚本,
14
+ * runImmediately 同步更新当前文档。任何异常都不阻断 agent 动作本身。
16
15
  */
17
- export declare function ensureControlledIndicator(session: PageSession): Promise<void>;
16
+ export declare function ensureControlledIndicator(session: PageSession, controlSource?: ControlSource): Promise<void>;
17
+ /** browser_release 使用:停止跨导航注入并恢复当前文档的 favicon。 */
18
+ export declare function releaseControlledIndicator(session: PageSession): Promise<void>;
@@ -0,0 +1,5 @@
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>;
@@ -12,6 +12,7 @@ import './tdbank-handlers.js';
12
12
  import './tab-handlers.js';
13
13
  import './interaction-handlers.js';
14
14
  import './timezone-handlers.js';
15
+ import './cookie-handlers.js';
15
16
  import './snapshot-handlers.js';
16
17
  import './recording-handlers.js';
17
18
  import './composite-handlers.js';
@@ -27,3 +28,4 @@ export { cdpPageSnapshot, cdpPageFrames } from './snapshot-handlers.js';
27
28
  export { cdpRecordStart, cdpRecordStop } from './recording-handlers.js';
28
29
  export { cdpRunActions, cdpObservedPageAction } from './composite-handlers.js';
29
30
  export { cdpSetTimezone } from './timezone-handlers.js';
31
+ export { cdpGetCookie, cdpSetCookie } from './cookie-handlers.js';
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * CDP HTTP proxy / MTOP request / API schema handlers.
3
3
  */
4
+ import { type GetApiSchemaParams, type SendMtopRequestParams, type SendRequestParams } from '@mearl/browser-core';
4
5
  import type { PageSession } from './cdp-session.js';
5
- export declare function cdpSendRequest(session: PageSession, data: any): Promise<any>;
6
- export declare function cdpSendMtopRequest(session: PageSession, data: any): Promise<any>;
7
- export declare function cdpGetApiSchema(session: PageSession, data: any): Promise<any>;
6
+ export declare function cdpSendRequest(session: PageSession, data: SendRequestParams): Promise<any>;
7
+ export declare function cdpSendMtopRequest(session: PageSession, data: SendMtopRequestParams): Promise<any>;
8
+ export declare function cdpGetApiSchema(session: PageSession, data: GetApiSchemaParams): Promise<any>;
@@ -3,14 +3,15 @@
3
3
  *
4
4
  * Covers: click, type, scroll, eval, press, wait, navigate, upload, device emulation.
5
5
  */
6
+ import { type PageClickParams, type PageEvalParams, type PageHoverParams, type PageNavigateParams, type PagePressParams, type PageScrollParams, type PageTypeParams, type PageUploadParams, type PageWaitParams, type SetDeviceEmulationParams } from '@mearl/browser-core';
6
7
  import type { PageSession } from './cdp-session.js';
7
- export declare function cdpPageClick(session: PageSession, data: any): Promise<any>;
8
- export declare function cdpPageType(session: PageSession, data: any): Promise<any>;
9
- export declare function cdpPageScroll(session: PageSession, data: any): Promise<any>;
10
- export declare function cdpPageEval(session: PageSession, data: any): Promise<any>;
11
- export declare function cdpPagePress(session: PageSession, data: any): Promise<any>;
12
- export declare function cdpPageWait(session: PageSession, data: any): Promise<any>;
13
- export declare function cdpPageNavigate(session: PageSession, data: any): Promise<any>;
14
- export declare function cdpPageUpload(session: PageSession, data: any): Promise<any>;
15
- export declare function cdpSetDeviceEmulation(session: PageSession, data: any): Promise<any>;
16
- export declare function cdpPageHover(session: PageSession, data: any): Promise<any>;
8
+ export declare function cdpPageClick(session: PageSession, data: PageClickParams): Promise<any>;
9
+ export declare function cdpPageType(session: PageSession, data: PageTypeParams): Promise<any>;
10
+ export declare function cdpPageScroll(session: PageSession, data: PageScrollParams): Promise<any>;
11
+ export declare function cdpPageEval(session: PageSession, data: PageEvalParams): Promise<any>;
12
+ export declare function cdpPagePress(session: PageSession, data: PagePressParams): Promise<any>;
13
+ export declare function cdpPageWait(session: PageSession, data: PageWaitParams): Promise<any>;
14
+ export declare function cdpPageNavigate(session: PageSession, data: PageNavigateParams): Promise<any>;
15
+ export declare function cdpPageUpload(session: PageSession, data: PageUploadParams): Promise<any>;
16
+ export declare function cdpSetDeviceEmulation(session: PageSession, data: SetDeviceEmulationParams): Promise<any>;
17
+ export declare function cdpPageHover(session: PageSession, data: PageHoverParams): Promise<any>;
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * CDP mock interception handlers.
3
3
  */
4
+ import { type GetMocksParams, type SetMockParams } from '@mearl/browser-core';
4
5
  import type { PageSession } from './cdp-session.js';
5
- export declare function cdpSetMock(session: PageSession, data: any): Promise<any>;
6
- export declare function cdpGetMocks(_session: PageSession, _data: any): any;
6
+ /** browser_release 使用:丢弃所有依赖当前 CDP 会话的 mock 状态。 */
7
+ export declare function clearCdpMockState(): void;
8
+ export declare function cdpSetMock(session: PageSession, data: SetMockParams): Promise<any>;
9
+ export declare function cdpGetMocks(_session: PageSession, _data: GetMocksParams): any;
@@ -4,6 +4,9 @@
4
4
  * Manages browser-side action recording via Runtime.addBinding +
5
5
  * Page.addScriptToEvaluateOnNewDocument.
6
6
  */
7
+ import { type RecordParams } from '@mearl/browser-core';
7
8
  import type { PageSession } from './cdp-session.js';
8
- export declare function cdpRecordStart(session: PageSession, _data: any): Promise<any>;
9
- export declare function cdpRecordStop(session: PageSession, _data: any): Promise<any>;
9
+ export declare function cdpRecordStart(session: PageSession, _data: RecordParams): Promise<any>;
10
+ export declare function cdpRecordStop(session: PageSession, _data: RecordParams): Promise<any>;
11
+ /** browser_release 使用:停止仍存活页面的录制,并丢弃已失效 target 的残留状态。 */
12
+ export declare function releaseCdpRecordings(sessions: PageSession[]): Promise<void>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Browser-level CDP control release.
3
+ *
4
+ * Closes Mearl's browser/page WebSocket sessions while keeping Chrome and all
5
+ * targets alive. A later browser action may create a fresh CdpSession.
6
+ */
7
+ import type { CdpSession } from './cdp-session.js';
8
+ export interface CdpReleaseResult {
9
+ released: boolean;
10
+ hadActiveControl: boolean;
11
+ affectedTabIds: number[];
12
+ }
13
+ export declare function releaseCdpControl(session: CdpSession): Promise<CdpReleaseResult>;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * CDP request/log/event buffer query handlers.
3
3
  */
4
+ import type { GetEventsParams, GetLogsParams, GetRequestsParams } from '@mearl/browser-core';
4
5
  import type { PageSession } from './cdp-session.js';
5
- export declare function cdpGetRequests(session: PageSession, data: any): Promise<any>;
6
- export declare function cdpGetLogs(session: PageSession, data: any): Promise<any>;
7
- export declare function cdpGetEvents(session: PageSession, data: any): Promise<any>;
6
+ export declare function cdpGetRequests(session: PageSession, data: GetRequestsParams): Promise<any>;
7
+ export declare function cdpGetLogs(session: PageSession, data: GetLogsParams): Promise<any>;
8
+ export declare function cdpGetEvents(session: PageSession, data: GetEventsParams): Promise<any>;
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * CDP accessibility tree snapshot and frame handlers.
3
3
  */
4
+ import { type PageFramesParams, type PageSnapshotParams } from '@mearl/browser-core';
4
5
  import type { PageSession } from './cdp-session.js';
5
- export declare function cdpPageSnapshot(session: PageSession, data: any): Promise<any>;
6
- export declare function cdpPageFrames(session: PageSession, _data: any): Promise<any>;
6
+ export declare function cdpPageSnapshot(session: PageSession, data: PageSnapshotParams): Promise<any>;
7
+ export declare function cdpPageFrames(session: PageSession, _data: PageFramesParams): Promise<any>;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * CDP tab management handlers.
3
3
  */
4
+ import { type ControlSource, type TabCloseParams, type TabOpenParams } from '@mearl/browser-core';
4
5
  import type { CdpSession } from './cdp-session.js';
5
- export declare function cdpTabOpen(session: CdpSession, data: any): Promise<any>;
6
- export declare function cdpTabClose(session: CdpSession, data: any): Promise<any>;
6
+ export declare function cdpTabOpen(session: CdpSession, data: TabOpenParams, controlSource?: ControlSource): Promise<any>;
7
+ export declare function cdpTabClose(session: CdpSession, data: TabCloseParams): Promise<any>;
7
8
  export declare function cdpTabList(session: CdpSession, _data: any): Promise<any>;
@@ -3,11 +3,12 @@
3
3
  *
4
4
  * Manages TDBank account listing, switching, borrowing via CDP cookie-based auth.
5
5
  */
6
+ import { type TdbankAccountParams } from '@mearl/browser-core';
6
7
  import type { CdpSession } from './cdp-session.js';
7
8
  /** Prepare a TDBank SSO ticket without changing the controller browser account. */
8
- export declare function cdpPrepareTdbankSso(cdpSession: CdpSession, data: any): Promise<any>;
9
+ export declare function cdpPrepareTdbankSso(cdpSession: CdpSession, data: TdbankAccountParams): Promise<any>;
9
10
  /** Consume a TDBank SSO ticket inside an isolated managed browser. */
10
11
  export declare function cdpConsumeTdbankSso(cdpSession: CdpSession, ssoUrl: string, expectedLoginId?: string): Promise<{
11
12
  nickname: string;
12
13
  }>;
13
- export declare function cdpTdbankAccount(cdpSession: CdpSession, data: any): Promise<any>;
14
+ export declare function cdpTdbankAccount(cdpSession: CdpSession, data: TdbankAccountParams): Promise<any>;
@@ -1,3 +1,4 @@
1
1
  /** CDP timezone override handler. */
2
+ import type { SetTimezoneParams } from '@mearl/browser-core';
2
3
  import type { PageSession } from './cdp-session.js';
3
- export declare function cdpSetTimezone(session: PageSession, data: any): Promise<any>;
4
+ export declare function cdpSetTimezone(session: PageSession, data: SetTimezoneParams): Promise<any>;
@@ -28,11 +28,14 @@
28
28
  * it. Connectors die only when explicitly stopped, when they exit on their own,
29
29
  * or when the machine reboots — never merely because the broker restarted.
30
30
  */
31
+ export interface CloudConnectorListItem {
32
+ serverUrl: string;
33
+ pid: number;
34
+ connectorId?: string;
35
+ name?: string;
36
+ }
31
37
  export interface CloudConnectorListResult {
32
- connectors: Array<{
33
- serverUrl: string;
34
- pid: number;
35
- }>;
38
+ connectors: CloudConnectorListItem[];
36
39
  }
37
40
  /**
38
41
  * Initialise module-level dependencies. Must be called before any other export.
@@ -46,6 +49,8 @@ export declare function initCloudConnector(deps: {
46
49
  export declare function startCloudConnector(serverUrl: string): Promise<{
47
50
  success: boolean;
48
51
  pid?: number;
52
+ connectorId?: string;
53
+ name?: string;
49
54
  reused?: boolean;
50
55
  error?: string;
51
56
  }>;