@mearl/native-host 2.0.2 → 2.1.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.
@@ -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,7 +18,8 @@ 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>;
22
24
  onEvent(listener: (event: AgentProviderEvent) => void): () => void;
23
25
  listSessions(options: AgentProviderListSessionsOptions): Promise<AgentProviderListSessionsResult>;
@@ -44,4 +46,5 @@ export declare class CodexAgentProvider implements AgentProvider {
44
46
  private extractThreadId;
45
47
  private probeExecutable;
46
48
  private resolveExecutable;
49
+ private resolveExecutableCandidates;
47
50
  }
@@ -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 {};
@@ -18,6 +18,7 @@ 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>;
23
24
  onEvent(listener: (event: AgentProviderEvent) => void): () => void;
@@ -48,5 +49,6 @@ export declare class QoderAgentProvider implements AgentProvider {
48
49
  private probeExecutable;
49
50
  private runSkillsList;
50
51
  private resolveExecutable;
52
+ private resolveExecutableCandidates;
51
53
  private emit;
52
54
  }
@@ -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;
@@ -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 { ControlSource } from '@mearl/browser-core';
11
12
  import type { CdpSession, PageSession } from './cdp-session.js';
12
13
  export interface BrowserAction {
13
14
  name: string;
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
19
  name: string;
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>;
@@ -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 } from '@mearl/browser-core';
11
+ export declare function cdpRunActions(session: CdpSession, data: any, 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,4 @@
1
+ /** CDP handler for changing one named cookie in the current page scope. */
2
+ import type { PageSession } from './cdp-session.js';
3
+ export declare function cdpSetCookie(session: PageSession, data: any): Promise<any>;
4
+ export declare function cdpGetCookie(session: PageSession, data: any): 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';
@@ -2,5 +2,7 @@
2
2
  * CDP mock interception handlers.
3
3
  */
4
4
  import type { PageSession } from './cdp-session.js';
5
+ /** browser_release 使用:丢弃所有依赖当前 CDP 会话的 mock 状态。 */
6
+ export declare function clearCdpMockState(): void;
5
7
  export declare function cdpSetMock(session: PageSession, data: any): Promise<any>;
6
8
  export declare function cdpGetMocks(_session: PageSession, _data: any): any;
@@ -7,3 +7,5 @@
7
7
  import type { PageSession } from './cdp-session.js';
8
8
  export declare function cdpRecordStart(session: PageSession, _data: any): Promise<any>;
9
9
  export declare function cdpRecordStop(session: PageSession, _data: any): Promise<any>;
10
+ /** browser_release 使用:停止仍存活页面的录制,并丢弃已失效 target 的残留状态。 */
11
+ 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 tab management handlers.
3
3
  */
4
+ import { type ControlSource } 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 cdpTabOpen(session: CdpSession, data: any, controlSource?: ControlSource): Promise<any>;
6
7
  export declare function cdpTabClose(session: CdpSession, data: any): Promise<any>;
7
8
  export declare function cdpTabList(session: CdpSession, _data: any): Promise<any>;