@mtop-devtools/native-host
Advanced tools
| /** Managed Chrome lifecycle for isolated, optionally headless browser instances. */ | ||
| import { type DaemonRecord } from '@mtop-devtools/daemon-core'; | ||
| import { type TransferableCookie } from './cdp-backend/cookie-transfer.js'; | ||
| export type ManagedBrowserUserAgentMode = 'default' | 'desktop'; | ||
| export interface ManagedBrowserLaunchParams { | ||
| name: string; | ||
| headless?: boolean; | ||
| userAgentMode?: ManagedBrowserUserAgentMode; | ||
| persistent?: boolean; | ||
@@ -68,2 +70,10 @@ executablePath?: string; | ||
| export declare function resolveChromeExecutable(explicitPath?: string): string; | ||
| export declare function desktopChromeUserAgent(version: string, platform?: NodeJS.Platform): string; | ||
| export declare function resolveChromeVersion(executablePath: string): string; | ||
| export declare function resolveUserAgentMode(value: unknown): ManagedBrowserUserAgentMode; | ||
| export declare function buildManagedChromeArgs(options: { | ||
| userDataDir: string; | ||
| headless: boolean; | ||
| userAgent?: string; | ||
| }): string[]; | ||
| /** Verify both PID liveness and the instance-specific command line before managing a process. */ | ||
@@ -70,0 +80,0 @@ export declare function isManagedProcess(pid: number, commandMarker: string, platform?: NodeJS.Platform): boolean; |
+3
-4
| { | ||
| "name": "@mtop-devtools/native-host", | ||
| "version": "1.41.1", | ||
| "version": "1.42.0", | ||
| "description": "Native Messaging Host for Mtop DevTools — bridges Chrome Extension and local socket server", | ||
@@ -31,8 +31,7 @@ "type": "module", | ||
| "devDependencies": { | ||
| "@agentclientprotocol/sdk": "^1.2.1", | ||
| "@types/node": "^24.9.1", | ||
| "esbuild": "^0.25.2", | ||
| "typescript": "^5.8.3", | ||
| "@mtop-devtools/browser-core": "1.41.1", | ||
| "@mtop-devtools/daemon-core": "1.41.1" | ||
| "@mtop-devtools/browser-core": "1.42.0", | ||
| "@mtop-devtools/daemon-core": "1.42.0" | ||
| }, | ||
@@ -39,0 +38,0 @@ "scripts": { |
+0
-24
@@ -66,26 +66,2 @@ # @mtop-devtools/native-host | ||
| ## 侧边栏 Agent Chat | ||
| 扩展侧边栏通过 Native Messaging 调用 native-host,再按用户选择启动持久的 Codex app-server 或 Qoder ACP 进程。两种 Provider 都支持流式消息、思考与工具进度、中断和审批,并复用各自 CLI 已保存的本地登录态。 | ||
| 需要先安装并登录支持 `app-server` 的 Codex CLI。若事件中的模型错误提示需要更新版本,应先升级本机 Codex CLI。native-host 会依次从安装时的 Node 可执行文件目录、常见全局安装目录和 `PATH` 查找 `codex`;自定义路径可通过环境变量指定: | ||
| ```bash | ||
| MTOP_DEVTOOLS_CODEX_PATH=/absolute/path/to/codex | ||
| ``` | ||
| Qoder 使用官方 ACP 接口,需要先安装 Qoder CLI 并完成登录: | ||
| ```bash | ||
| # macOS / Linux | ||
| curl -fsSL https://qoder.com/install | bash | ||
| qodercli | ||
| # 进入交互界面后输入 /login | ||
| # 可选:指定非标准安装位置 | ||
| MTOP_DEVTOOLS_QODER_PATH=/absolute/path/to/qodercli | ||
| ``` | ||
| 侧边栏中未选择本地目录时,Codex 对话使用只读沙箱且不允许提权;选择后才使用该目录作为可写工作区。Qoder ACP 对话必须先选择本地目录。`MTOP_DEVTOOLS_AGENT_CWD` 仅用于 Codex 只读对话的默认浏览目录,不会开启写权限。Agent 接入由统一 Provider 接口承载,后续可新增 Claude 等实现而无需修改扩展与 native-host 之间的 Chat 协议。只安装 ChatGPT 等桌面聊天客户端不能替代 Provider CLI;侧边栏会在 CLI 缺失时展示安装与登录指引。 | ||
| ## 构建 | ||
@@ -92,0 +68,0 @@ |
| import type { AgentChatImageInput, AgentChatProviderDescriptor } from '@mtop-devtools/browser-core'; | ||
| import type { AgentProvider, AgentProviderEvent, AgentProviderListSessionsOptions, AgentProviderListSessionsResult, AgentProviderResumeResult, AgentProviderSessionOptions } from './provider.js'; | ||
| export declare function codexThreadUrl(providerSessionId: string): string; | ||
| export declare function externalOpenCommand(url: string, platform?: NodeJS.Platform): { | ||
| command: string; | ||
| args: string[]; | ||
| }; | ||
| export declare class CodexAgentProvider implements AgentProvider { | ||
| private readonly log; | ||
| private readonly clientVersion; | ||
| readonly id = "codex"; | ||
| private process; | ||
| private initialized; | ||
| private startPromise; | ||
| private nextRequestId; | ||
| private pendingRequests; | ||
| private listeners; | ||
| private knownThreadIds; | ||
| constructor(log: (...args: any[]) => void, clientVersion: string); | ||
| getDescriptor(): Promise<AgentChatProviderDescriptor>; | ||
| onEvent(listener: (event: AgentProviderEvent) => void): () => void; | ||
| listSessions(options: AgentProviderListSessionsOptions): Promise<AgentProviderListSessionsResult>; | ||
| startSession(options: AgentProviderSessionOptions): Promise<string>; | ||
| resumeSession(providerSessionId: string, options: AgentProviderSessionOptions): Promise<AgentProviderResumeResult>; | ||
| sendMessage(providerSessionId: string, message: string, images?: AgentChatImageInput[]): Promise<{ | ||
| turnId: string; | ||
| }>; | ||
| interrupt(providerSessionId: string, turnId: string): Promise<void>; | ||
| closeSession(providerSessionId: string): Promise<void>; | ||
| openSession(providerSessionId: string): Promise<void>; | ||
| respondToRequest(requestId: string | number, result: unknown): void; | ||
| dispose(): void; | ||
| private ensureStarted; | ||
| private start; | ||
| private handleLine; | ||
| private request; | ||
| private write; | ||
| private handleExit; | ||
| private rejectPending; | ||
| private emit; | ||
| private extractThreadId; | ||
| private probeExecutable; | ||
| private resolveExecutable; | ||
| } |
| import type { AgentChatEvent } from '@mtop-devtools/browser-core'; | ||
| export declare const MAX_AGENT_EVENT_BYTES: number; | ||
| export declare function sanitizeAgentChatEvent(event: AgentChatEvent): AgentChatEvent; |
| export declare function createBrowserDeveloperInstructions(tabId: number): string; |
| import type { AgentChatEvent, AgentChatCloseOptions, AgentChatEventsOptions, AgentChatEventsResult, AgentChatInterruptOptions, AgentChatListSessionsOptions, AgentChatListSessionsResult, AgentChatOpenOptions, AgentChatRefreshResult, AgentChatRespondOptions, AgentChatSendOptions, AgentChatSession, AgentChatStartOptions, AgentChatStatus } from '@mtop-devtools/browser-core'; | ||
| import type { AgentProvider } from './provider.js'; | ||
| export declare class AgentChatManager { | ||
| private readonly emit; | ||
| private readonly providers; | ||
| private readonly sessions; | ||
| private readonly sessionByProviderThread; | ||
| private readonly pendingRequests; | ||
| private readonly completedTurns; | ||
| private readonly recentEvents; | ||
| private readonly recentEventBytes; | ||
| private readonly unsubscribe; | ||
| constructor(providers: AgentProvider[], emit: (event: AgentChatEvent) => void); | ||
| getStatus(): Promise<AgentChatStatus>; | ||
| listSessions(options: AgentChatListSessionsOptions): Promise<AgentChatListSessionsResult>; | ||
| startSession(options: AgentChatStartOptions): Promise<AgentChatSession>; | ||
| sendMessage(options: AgentChatSendOptions): Promise<{ | ||
| turnId: string; | ||
| }>; | ||
| interrupt(options: AgentChatInterruptOptions): Promise<void>; | ||
| openSession(options: AgentChatOpenOptions): Promise<void>; | ||
| closeSession(options: AgentChatCloseOptions): Promise<void>; | ||
| getEvents(options: AgentChatEventsOptions): AgentChatEventsResult; | ||
| refreshSession(options: AgentChatEventsOptions): Promise<AgentChatRefreshResult>; | ||
| respondToRequest(options: AgentChatRespondOptions): void; | ||
| dispose(): void; | ||
| private handleProviderEvent; | ||
| private emitEvent; | ||
| private recordEvent; | ||
| private getProvider; | ||
| private getSession; | ||
| private providerThreadKey; | ||
| private providerRequestKey; | ||
| private sessionTurnKey; | ||
| } |
| export interface AgentSpawnCommand { | ||
| command: string; | ||
| args: string[]; | ||
| } | ||
| export declare function agentSpawnCommand(executable: string, args: string[], platform?: NodeJS.Platform, commandInterpreter?: string | undefined): AgentSpawnCommand; | ||
| export declare function createAgentChildEnv(sourceEnv?: NodeJS.ProcessEnv, nodeExecutable?: string): NodeJS.ProcessEnv; |
| import type { AgentChatEventKind, AgentChatImageInput, AgentChatProviderDescriptor } from '@mtop-devtools/browser-core'; | ||
| export interface AgentProviderEvent { | ||
| providerSessionId?: string; | ||
| kind: AgentChatEventKind; | ||
| method: string; | ||
| params: unknown; | ||
| timestamp?: number; | ||
| requestId?: string | number; | ||
| } | ||
| export interface AgentProviderSessionOptions { | ||
| cwd?: string; | ||
| developerInstructions?: string; | ||
| ephemeral?: boolean; | ||
| } | ||
| export interface AgentProviderSessionSummary { | ||
| providerSessionId: string; | ||
| title?: string; | ||
| cwd?: string; | ||
| updatedAt?: number; | ||
| ephemeral?: boolean; | ||
| } | ||
| export interface AgentProviderListSessionsOptions { | ||
| cwd?: string; | ||
| cursor?: string; | ||
| limit: number; | ||
| } | ||
| export interface AgentProviderListSessionsResult { | ||
| sessions: AgentProviderSessionSummary[]; | ||
| nextCursor?: string; | ||
| } | ||
| export interface AgentProviderResumeResult { | ||
| providerSessionId: string; | ||
| history?: AgentProviderEvent[]; | ||
| historyComplete?: boolean; | ||
| } | ||
| export interface AgentProvider { | ||
| readonly id: string; | ||
| getDescriptor(): Promise<AgentChatProviderDescriptor>; | ||
| onEvent(listener: (event: AgentProviderEvent) => void): () => void; | ||
| listSessions?(options: AgentProviderListSessionsOptions): Promise<AgentProviderListSessionsResult>; | ||
| startSession(options: AgentProviderSessionOptions): Promise<string>; | ||
| resumeSession(providerSessionId: string, options: AgentProviderSessionOptions): Promise<AgentProviderResumeResult>; | ||
| validateMessageInput?(images: AgentChatImageInput[]): Promise<void>; | ||
| sendMessage(providerSessionId: string, message: string, images?: AgentChatImageInput[]): Promise<{ | ||
| turnId: string; | ||
| }>; | ||
| interrupt(providerSessionId: string, turnId: string): Promise<void>; | ||
| closeSession(providerSessionId: string): Promise<void>; | ||
| openSession?(providerSessionId: string): Promise<void>; | ||
| respondToRequest(requestId: string | number, result: unknown): void; | ||
| dispose(): void; | ||
| } |
| import type { AgentChatImageInput, AgentChatProviderDescriptor } from '@mtop-devtools/browser-core'; | ||
| import type { AgentProvider, AgentProviderEvent, AgentProviderListSessionsOptions, AgentProviderListSessionsResult, AgentProviderResumeResult, AgentProviderSessionOptions } from './provider.js'; | ||
| export declare function qoderInstallCommand(platform?: NodeJS.Platform): string; | ||
| export declare class QoderAgentProvider implements AgentProvider { | ||
| private readonly log; | ||
| private readonly clientVersion; | ||
| readonly id = "qoder"; | ||
| private process; | ||
| private connection; | ||
| private context; | ||
| private initializeResponse; | ||
| private startPromise; | ||
| private listeners; | ||
| private sessions; | ||
| private pendingPermissions; | ||
| private historyCaptures; | ||
| private nextTurnId; | ||
| constructor(log: (...args: any[]) => void, clientVersion: string); | ||
| getDescriptor(): Promise<AgentChatProviderDescriptor>; | ||
| onEvent(listener: (event: AgentProviderEvent) => void): () => void; | ||
| listSessions(options: AgentProviderListSessionsOptions): Promise<AgentProviderListSessionsResult>; | ||
| startSession(options: AgentProviderSessionOptions): Promise<string>; | ||
| resumeSession(providerSessionId: string, options: AgentProviderSessionOptions): Promise<AgentProviderResumeResult>; | ||
| validateMessageInput(images: AgentChatImageInput[]): Promise<void>; | ||
| sendMessage(providerSessionId: string, message: string, images?: AgentChatImageInput[]): Promise<{ | ||
| turnId: string; | ||
| }>; | ||
| interrupt(providerSessionId: string, _turnId: string): Promise<void>; | ||
| closeSession(providerSessionId: string): Promise<void>; | ||
| respondToRequest(requestId: string | number, result: unknown): void; | ||
| dispose(): void; | ||
| private ensureStarted; | ||
| private start; | ||
| private runPrompt; | ||
| private handleSessionUpdate; | ||
| private emitToolUpdate; | ||
| private handlePermissionRequest; | ||
| private cancelPermissions; | ||
| private handleExit; | ||
| private getContext; | ||
| private assertImageInputSupported; | ||
| private withTimeout; | ||
| private probeExecutable; | ||
| private resolveExecutable; | ||
| private emit; | ||
| } |
| export type DirectoryPickerRunner = (command: string, args: string[]) => Promise<string | null>; | ||
| export declare const runDirectoryPickerCommand: DirectoryPickerRunner; | ||
| export declare function pickWorkspaceDirectory(platform?: NodeJS.Platform, run?: DirectoryPickerRunner): Promise<string | null>; | ||
| export declare function resolveWorkspaceDirectory(directory: unknown): string; |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
5
-16.67%25
-30.56%14
-12.5%296910
-69.21%33
-19.51%8201
-70.11%76
-24%