assistant/electron/shared.ts

58 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 主进程、preload、渲染层共用的类型(只做类型导入)
export interface ViewBounds {
x: number;
y: number;
width: number;
height: number;
}
export interface ViewportMessage {
taskId?: string;
visible: boolean;
bounds?: ViewBounds;
}
export type ViewMode = 'agent' | 'user';
export interface BrowserStateEvent {
taskId: string;
url: string;
title: string;
loading: boolean;
mode: ViewMode;
}
export interface RevealEvent {
taskId: string;
}
export interface AppMeta {
apiPort: number;
cdpPort: number;
controlPort: number;
version: string;
}
export interface AssistantBridge {
/** Trusted, static desktop chrome facts; absent in ordinary browser previews. */
readonly desktopChrome?: {
readonly platform: string;
readonly titleBar: 'mac-inset' | 'native';
};
get: (path: string) => Promise<unknown>;
post: (path: string, body?: unknown) => Promise<unknown>;
put: (path: string, body?: unknown) => Promise<unknown>;
del: (path: string) => Promise<unknown>;
openPath: (filePath: string) => Promise<string>;
meta: () => Promise<AppMeta>;
browser: {
viewport: (message: ViewportMessage) => Promise<void>;
mode: (taskId: string, mode: ViewMode) => Promise<void>;
onState: (handler: (event: BrowserStateEvent) => void) => () => void;
onReveal: (handler: (event: RevealEvent) => void) => () => void;
onHide: (handler: (event: RevealEvent) => void) => () => void;
onUserInput: (handler: (event: RevealEvent) => void) => () => void;
};
}