import type { RawMessage } from '@runtime/shared/chat-model'; export type RuntimeRefreshTopic = | 'providers' | 'models' | 'agents' | 'channels' | 'channel-targets'; /// 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'; } | { type: 'runtime:changed'; topics: RuntimeRefreshTopic[]; reason?: string; syncedAt: string; warnings?: string[]; channelType?: string; accountId?: string; }; /// 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; 'session.delete': { sessionKey: string; }; 'provider.list': Record; 'provider.getDefault': Record; } /// 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 }; }