import type { Task } from '@lib/task-types'; import type { RawMessage } from '@shared/chat-model'; export type ThemeMode = 'light' | 'dark' | 'system'; export type ResolvedThemeMode = 'light' | 'dark'; export type LanguageCode = 'en' | 'zh' | 'ja'; export type RuntimePlatform = 'win32' | 'darwin' | 'linux' | 'web' | 'unknown'; export type WindowName = 'main' | 'setting' | 'dialog' | 'loading'; export type IpcArgs = readonly unknown[]; export type IpcListener = (...args: unknown[]) => void; export const CONFIG_KEYS = { THEME_MODE: 'themeMode', PRIMARY_COLOR: 'primaryColor', LANGUAGE: 'language', FONT_SIZE: 'fontSize', MINIMIZE_TO_TRAY: 'minimizeToTray', PROVIDER: 'provider', DEFAULT_MODEL: 'defaultModel', SELECTED_CHANNELS: 'selectedChannels', IMAGE_CACHE: 'imageCache', TASK_LIST: 'taskList', } as const; export type ConfigKey = (typeof CONFIG_KEYS)[keyof typeof CONFIG_KEYS]; export type ConfigValueKey = keyof ConfigValueMap; export interface ConfigValueMap { themeMode: ThemeMode; primaryColor: string; language: LanguageCode; fontSize: number; minimizeToTray: boolean; provider: string | null; defaultModel: string | null; selectedChannels: Array<{ id: string; channelName: string; channelUrl: string }>; imageCache: Array<[string, unknown]>; taskList: Task[]; } export interface WindowApiBridge { versions?: Record; platform?: string; invoke?(channel: string, ...args: IpcArgs): Promise; invokeAsync?(channel: string, ...args: IpcArgs): Promise; on?(channel: string, callback: IpcListener): () => void; send?(channel: string, ...args: IpcArgs): void; getCurrentWindowId?(): string | number; } export interface WindowIdentity { platform: RuntimePlatform; windowId: string | number | null; windowName: WindowName; isElectron: boolean; } export interface HostApiResult { success?: boolean; ok?: boolean; json?: T; data?: T | { json?: T }; text?: string; error?: string; status?: number; } export type GatewayEvent = | { type: 'chat:delta'; sessionKey: string; runId: string; delta: string; } | { type: 'chat:final'; sessionKey: string; runId: string; message: RawMessage; } | { type: 'chat:error'; sessionKey: string; runId: string; error: string; } | { type: 'chat:aborted'; sessionKey: string; runId: string; } | { type: 'gateway:status'; status: 'connected' | 'disconnected' | 'reconnecting'; }; export {};