Files
zn-ai/electron/gateway/types.ts
DEV_DSW 79bea4f107 Refactor UUID generation, remove unused logger and encryption utilities, and clean up request handling
- Updated `generateUUID` function for improved readability and performance.
- Deleted `logger.ts`, `other.ts`, `request.ts`, `storage.ts`, `tansParams.ts`, and `validate.ts` as they were no longer needed.
- Simplified TypeScript configuration by removing unnecessary paths and aliases.
- Enhanced Vite configuration for better project structure and maintainability.
2026-04-17 15:38:08 +08:00

67 lines
1.5 KiB
TypeScript

import type { RawMessage } from '@runtime/shared/chat-model';
/// 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>;
'session.delete': {
sessionKey: string;
};
'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[];
'session.delete': { success: boolean };
'provider.list': { accounts: any[]; defaultAccountId: string | null };
'provider.getDefault': { accountId: string | null };
}