Files
makelore/electron/api/context.ts

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 { createWorksSubmissionBindingStore } from '../services/works-submission-binding';
import type { DesignWorkspaceModule } from '../image-workspace/module';
import type {
AgentBrowserBounds,
AgentBrowserCdpEventPage,
AgentBrowserCdpResult,
AgentBrowserPayloadChunk,
AgentBrowserSnapshot,
} from '../../shared/agent-browser';
export type WorksSubmissionBindingStore = ReturnType<typeof createWorksSubmissionBindingStore>;
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;
worksSubmissionBinding?: WorksSubmissionBindingStore;
imageWorkspace?: DesignWorkspaceModule;
}