Files
zn-ai/electron/gateway/types.ts
duanshuwen 38bea97197 feat: Enhance Marketplace and Skill Management UI with improved error handling and user feedback
- Updated MarketplaceDrawer to include security notes and manual installation hints.
- Refactored SkillDetailDrawer to display default icons for skills.
- Simplified SkillListItem to use default icons for better readability.
- Integrated gateway status checks and warnings in SkillsPage for improved user awareness.
- Enhanced error handling for skill installation and fetching, providing clearer feedback to users.
- Added new translations for error messages and gateway warnings to improve localization support.
2026-04-19 20:33:44 +08:00

107 lines
2.3 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>;
'skills.status': Record<string, never>;
'skills.update': {
skillKey: string;
enabled?: boolean;
};
}
/// 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 };
'skills.status': {
skills: Array<{
skillKey: string;
slug?: string;
name?: string;
description?: string;
disabled?: boolean;
emoji?: string;
version?: string;
author?: string;
config?: Record<string, unknown>;
bundled?: boolean;
always?: boolean;
source?: string;
baseDir?: string;
filePath?: string;
}>;
};
'skills.update': { success: boolean };
}