/** * Sync Catalog Action * * Manually trigger a sync of the skill catalog from the registry. */ import type { Action, IAgentRuntime, Memory, State, HandlerCallback, ActionResult, } from "@elizaos/core"; import type { AgentSkillsService } from "../services/skills"; export const syncCatalogAction: Action = { name: "SYNC_SKILL_CATALOG", similes: ["REFRESH_SKILLS", "UPDATE_CATALOG"], description: "Sync the skill catalog from the registry to discover new skills.", validate: async ( runtime: IAgentRuntime, _message: Memory, ): Promise => { const service = runtime.getService( "AGENT_SKILLS_SERVICE", ); return !!service; }, handler: async ( runtime: IAgentRuntime, _message: Memory, _state: State | undefined, _options: unknown, callback?: HandlerCallback, ): Promise => { try { const service = runtime.getService( "AGENT_SKILLS_SERVICE", ); if (!service) { throw new Error("AgentSkillsService not available"); } runtime.logger.info("AgentSkills: Manual catalog sync triggered"); const result = await service.syncCatalog(); const text = `Skill catalog synced successfully. - Total skills: ${result.updated} - New skills: ${result.added}`; if (callback) await callback({ text }); return { success: true, text, data: result, }; } catch (error) { const errorMsg = error instanceof Error ? error.message : String(error); if (callback) { await callback({ text: `Error syncing catalog: ${errorMsg}` }); } return { success: false, error: error instanceof Error ? error : new Error(errorMsg), }; } }, examples: [ [ { name: "{{userName}}", content: { text: "Refresh the skill catalog" } }, { name: "{{agentName}}", content: { text: "Skill catalog synced successfully.\n- Total skills: 150\n- New skills: 5", actions: ["SYNC_SKILL_CATALOG"], }, }, ], ], }; export default syncCatalogAction;