merge: 集成共享 Agent Browser 调试能力
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

需求:将 Agent Browser 独立功能提交合并到包含 AI 设计 Workspace 的最新主线。

实现:保留双方模块初始化、Host API 路由和 README 产品说明。

# Conflicts:
#	electron/api/context.ts
This commit is contained in:
2026-07-31 14:56:45 +08:00
39 changed files with 6734 additions and 9 deletions

View File

@@ -4,14 +4,66 @@ import type { OpencodeProjectStore } from '../opencode/project-store';
import type { HostEventBus } from './event-bus';
import type { createWorksCloudDeployment } from '../services/works-cloud-deployment';
import type { DesignWorkspaceModule } from '../image-workspace/module';
import type {
AgentBrowserBounds,
AgentBrowserCdpEventPage,
AgentBrowserCdpResult,
AgentBrowserPayloadChunk,
AgentBrowserSnapshot,
} from '../../shared/agent-browser';
export type WorksCloudDeploymentCoordinator = ReturnType<typeof createWorksCloudDeployment>;
export interface AgentBrowserService {
getSnapshot(projectPath?: string): Promise<AgentBrowserSnapshot> | AgentBrowserSnapshot;
open(input: {
projectId: string;
projectPath: string;
url: string;
bounds?: AgentBrowserBounds;
visible?: boolean;
}): Promise<AgentBrowserSnapshot>;
present(input: {
projectPath: string;
visible: boolean;
bounds?: AgentBrowserBounds;
}): Promise<AgentBrowserSnapshot>;
navigate(input: {
projectPath: string;
action: 'url' | 'back' | 'forward' | 'reload';
url?: string;
}): Promise<AgentBrowserSnapshot>;
sendCdp(input: {
projectPath: string;
method: string;
params?: Record<string, unknown>;
sessionRef?: string;
timeoutMs?: number;
}): Promise<AgentBrowserCdpResult>;
readEvents(input: {
projectPath: string;
after?: number;
methods?: string[];
limit?: number;
waitMs?: number;
}): Promise<AgentBrowserCdpEventPage>;
readPayload(input: {
projectPath: string;
handle: string;
offset?: number;
maxBytes?: number;
}): Promise<AgentBrowserPayloadChunk>;
close(projectPath?: string): Promise<AgentBrowserSnapshot>;
resetProfile(projectPath: string): Promise<AgentBrowserSnapshot>;
dispose(): Promise<void>;
}
export interface HostApiContext {
opencodeManager: OpencodeManager;
opencodeProjectStore: OpencodeProjectStore;
eventBus: HostEventBus;
mainWindow: BrowserWindow | null;
agentBrowser?: AgentBrowserService;
worksCloudDeployment?: WorksCloudDeploymentCoordinator;
imageWorkspace?: DesignWorkspaceModule;
}