feat: add runtime event handling for providers in ProvidersSection feat: update routing to include Channels and Agents pages feat: extend route types and navigation items for Channels and Agents feat: implement agents store for managing agent data and interactions fix: update chat store to utilize agents store for agent-related functionality chore: export agents store from index fix: enhance runtime types for better event handling fix: update Vite config to handle dev server URL correctly
83 lines
1.8 KiB
TypeScript
83 lines
1.8 KiB
TypeScript
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<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 };
|
|
}
|