( skillInputs: SkillInput[], workspaceId: string )
| 25 | * Only returns lightweight data so the LLM knows what skills are available. |
| 26 | */ |
| 27 | export async function resolveSkillMetadata( |
| 28 | skillInputs: SkillInput[], |
| 29 | workspaceId: string |
| 30 | ): Promise<SkillMetadata[]> { |
| 31 | if (!skillInputs.length || !workspaceId) return [] |
| 32 | |
| 33 | const metadata: SkillMetadata[] = [] |
| 34 | const dbSkillIds: string[] = [] |
| 35 | for (const input of skillInputs) { |
| 36 | const builtin = getBuiltinSkillById(input.skillId) |
| 37 | if (builtin) { |
| 38 | metadata.push({ name: builtin.name, description: builtin.description }) |
| 39 | } else { |
| 40 | dbSkillIds.push(input.skillId) |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | if (dbSkillIds.length === 0) return metadata |
| 45 | |
| 46 | try { |
| 47 | const rows = await db |
| 48 | .select({ name: skill.name, description: skill.description }) |
| 49 | .from(skill) |
| 50 | .where(and(eq(skill.workspaceId, workspaceId), inArray(skill.id, dbSkillIds))) |
| 51 | |
| 52 | return [...metadata, ...rows] |
| 53 | } catch (error) { |
| 54 | logger.error('Failed to resolve skill metadata', { error, dbSkillIds, workspaceId }) |
| 55 | return metadata |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Fetch full skill content for a load_skill tool response. |
no test coverage detected