feat: 重构对话功能

This commit is contained in:
DEV_DSW
2026-04-14 17:02:20 +08:00
parent b3f07c4cfe
commit c61e41049f
53 changed files with 5200 additions and 1982 deletions

62
electron/gateway/types.ts Normal file
View File

@@ -0,0 +1,62 @@
import type { RawMessage } from '@src/pages/home/model/ChatModel';
/// Gateway 向 Renderer 推送的事件类型
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';
};
/// Gateway RPC 方法参数映射
export interface GatewayRpcParams {
'chat.send': {
sessionKey: string;
message: RawMessage;
options?: {
providerAccountId?: string;
};
};
'chat.history': {
sessionKey: string;
limit?: number;
};
'chat.abort': {
sessionKey: string;
};
'session.list': Record<string, never>;
'provider.list': Record<string, never>;
'provider.getDefault': Record<string, never>;
}
/// Gateway RPC 方法返回值映射
export interface GatewayRpcReturns {
'chat.send': { runId: string };
'chat.history': RawMessage[];
'chat.abort': void;
'session.list': string[];
'provider.list': { accounts: any[]; defaultAccountId: string | null };
'provider.getDefault': { accountId: string | null };
}