- 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.
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { getAllSkillConfigs, updateSkillConfig } from '@electron/utils/skill-config';
|
|
import type { GatewayRpcReturns } from '../types';
|
|
|
|
export async function handleSkillsStatus(): Promise<GatewayRpcReturns['skills.status']> {
|
|
const configs = await getAllSkillConfigs();
|
|
|
|
return {
|
|
skills: Object.entries(configs).map(([skillKey, config]) => ({
|
|
skillKey,
|
|
slug: config.slug || skillKey,
|
|
name: config.name || skillKey,
|
|
description: config.description || '',
|
|
disabled: config.enabled === false,
|
|
emoji: config.icon,
|
|
version: config.version || '1.0.0',
|
|
author: config.author,
|
|
config: {
|
|
...(config.config || {}),
|
|
...(config.apiKey ? { apiKey: config.apiKey } : {}),
|
|
...(config.env ? { env: config.env } : {}),
|
|
},
|
|
bundled: typeof config.isBundled === 'boolean' ? config.isBundled : config.source === 'openclaw-bundled',
|
|
always: Boolean(config.isCore),
|
|
source: config.source,
|
|
baseDir: config.baseDir,
|
|
filePath: config.filePath,
|
|
})),
|
|
};
|
|
}
|
|
|
|
export async function handleSkillsUpdate(
|
|
params: { skillKey: string; enabled?: boolean },
|
|
): Promise<GatewayRpcReturns['skills.update']> {
|
|
const { skillKey, enabled } = params;
|
|
if (!skillKey || !String(skillKey).trim()) {
|
|
throw new Error('skillKey is required');
|
|
}
|
|
|
|
const result = await updateSkillConfig(String(skillKey).trim(), { enabled });
|
|
if (!result.success) {
|
|
throw new Error(result.error || 'Failed to update skill');
|
|
}
|
|
|
|
return { success: true };
|
|
}
|