需求:将 Agent Browser 独立功能提交合并到包含 AI 设计 Workspace 的最新主线。 实现:保留双方模块初始化、Host API 路由和 README 产品说明。 # Conflicts: # electron/api/context.ts
70 lines
2.2 KiB
TypeScript
70 lines
2.2 KiB
TypeScript
import type { BrowserWindow } from 'electron';
|
|
import type { OpencodeManager } from '../opencode/manager';
|
|
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;
|
|
}
|