/** * Get Skill Details Action * * Get detailed information about a specific skill from the registry. */ import type { Action, IAgentRuntime, Memory, State, HandlerCallback, ActionResult, } from "@elizaos/core"; import type { AgentSkillsService } from "../services/skills"; export const getSkillDetailsAction: Action = { name: "GET_SKILL_DETAILS", similes: ["SKILL_INFO", "SKILL_DETAILS"], description: "Get detailed information about a specific skill including version, owner, and stats.", 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"); } const opts = options as { slug?: string } | undefined; const slug = opts?.slug || extractSlugFromText(message.content?.text || ""); if (!slug) { return { success: false, error: new Error("Skill slug is required"), }; } const details = await service.getSkillDetails(slug); if (!details) { const text = `Skill "${slug}" not found in the registry.`; if (callback) await callback({ text }); return { success: false, error: new Error(text) }; } const isInstalled = await service.isInstalled(slug); const text = `## ${details.skill.displayName} **Slug:** \`${details.skill.slug}\` **Version:** ${details.latestVersion.version} **Status:** ${isInstalled ? "✅ Installed" : "📦 Available"} ${details.skill.summary} **Stats:** - Downloads: ${details.skill.stats.downloads} - Stars: ${details.skill.stats.stars} - Versions: ${details.skill.stats.versions} ${details.owner ? `**Author:** ${details.owner.displayName} (@${details.owner.handle})` : ""} ${details.latestVersion.changelog ? `**Changelog:** ${details.latestVersion.changelog}` : ""}`; if (callback) await callback({ text }); return { success: true, text, data: { details, isInstalled }, }; } catch (error) { const errorMsg = error instanceof Error ? error.message : String(error); if (callback) { await callback({ text: `Error getting skill details: ${errorMsg}` }); } return { success: false, error: error instanceof Error ? error : new Error(errorMsg), }; } }, examples: [ [ { name: "{{userName}}", content: { text: "Tell me about the pdf-processing skill" }, }, { name: "{{agentName}}", content: { text: "## PDF Processing\n\n**Slug:** `pdf-processing`\n**Version:** 1.2.0\n**Status:** ✅ Installed...", actions: ["GET_SKILL_DETAILS"], }, }, ], ], }; function extractSlugFromText(text: string): string | null { // Try to extract a slug-like pattern const match = text.match(/\b([a-z][a-z0-9-]*[a-z0-9])\b/); return match ? match[1] : null; } export default getSkillDetailsAction;