@mastra/core
Version:
1 lines • 22.9 kB
Source Map (JSON)
{"version":3,"file":"agent-skills-resolver-BfwRVTvX.cjs","names":["validateSkillMetadata","#skills","#skillMdCache","#buildSkillMd","matter","#parsePath","#getSkill","#local","#inline","#route","LocalSkillSource","WorkspaceSkillsImpl","#primary","#secondary"],"sources":["../src/skills/create-skill.ts","../src/skills/inline-skill-source.ts","../src/skills/agent-skills-resolver.ts"],"sourcesContent":["/**\n * createSkill() — factory for creating inline skills in code.\n *\n * Creates a Skill object that can be passed to an Agent's `skills` config\n * without requiring a Workspace or filesystem.\n *\n * @example\n * ```typescript\n * import { createSkill } from '@mastra/core/skills';\n *\n * const reviewSkill = createSkill({\n * name: 'code-review',\n * description: 'Use when reviewing code changes.',\n * instructions: `\n * When reviewing code:\n * 1. Check for correctness\n * 2. Check for style consistency\n * 3. Look for potential bugs\n * `,\n * references: {\n * 'checklist.md': '# Review Checklist\\n...',\n * },\n * });\n * ```\n */\n\nimport { validateSkillMetadata } from '../workspace/skills/schemas';\nimport type { InlineSkill, InlineSkillInput } from './types';\n\n/**\n * Create an inline skill from code — no filesystem needed.\n *\n * The returned object implements the `Skill` interface and can be passed\n * directly to an Agent's `skills` config or used anywhere a `Skill` is expected.\n *\n * @throws Error if the skill metadata fails validation\n */\nexport function createSkill(input: InlineSkillInput): InlineSkill {\n const { name, description, instructions, license, compatibility, metadata, references } = input;\n\n // Validate metadata (same checks as filesystem-discovered skills)\n const validation = validateSkillMetadata(\n { name, description, license, compatibility, 'user-invocable': input['user-invocable'], metadata },\n undefined,\n instructions,\n );\n\n if (!validation.valid) {\n throw new Error(`Invalid skill \"${name}\": ${validation.errors.join('; ')}`);\n }\n\n const referenceKeys = references ? Object.keys(references) : [];\n\n return {\n __inline: true as const,\n __referenceContents: references ?? {},\n name,\n description,\n instructions,\n license,\n compatibility,\n 'user-invocable': input['user-invocable'],\n metadata,\n // Inline skills use a synthetic path: `inline/<name>`\n path: `inline/${name}`,\n source: { type: 'local', projectPath: `inline/${name}` },\n references: referenceKeys,\n scripts: [],\n assets: [],\n };\n}\n\n/**\n * Type guard: is this skill an inline skill (from createSkill)?\n */\nexport function isInlineSkill(skill: unknown): skill is InlineSkill {\n return typeof skill === 'object' && skill !== null && '__inline' in skill && (skill as InlineSkill).__inline === true;\n}\n","/**\n * InlineSkillSource — in-memory SkillSource for code-defined skills.\n *\n * Serves skills created via `createSkill()` without any filesystem dependency.\n * Implements the SkillSource interface so it can be used with WorkspaceSkillsImpl.\n *\n * Directory layout emulation:\n * Each inline skill appears as a directory at `inline/<name>/` with:\n * - SKILL.md (generated from the skill's metadata + instructions)\n * - references/<file> (from the skill's `references` map)\n */\n\nimport matter from 'gray-matter';\n\nimport type { SkillSource, SkillSourceEntry, SkillSourceStat } from '../workspace/skills/skill-source';\nimport type { InlineSkill } from './types';\n\nexport class InlineSkillSource implements SkillSource {\n readonly #skills: Map<string, InlineSkill>;\n /** Pre-built SKILL.md content per skill name */\n readonly #skillMdCache: Map<string, string>;\n\n constructor(skills: InlineSkill[]) {\n this.#skills = new Map(skills.map(s => [s.name, s]));\n this.#skillMdCache = new Map();\n\n for (const skill of skills) {\n this.#skillMdCache.set(skill.name, this.#buildSkillMd(skill));\n }\n }\n\n /**\n * Build a synthetic SKILL.md from an inline skill's metadata and instructions.\n */\n #buildSkillMd(skill: InlineSkill): string {\n const frontmatter: Record<string, unknown> = {\n name: skill.name,\n description: skill.description,\n };\n if (skill.license) frontmatter.license = skill.license;\n if (skill.compatibility) frontmatter.compatibility = skill.compatibility;\n if (skill['user-invocable'] !== undefined) frontmatter['user-invocable'] = skill['user-invocable'];\n if (skill.metadata) frontmatter.metadata = skill.metadata;\n\n return matter.stringify(skill.instructions, frontmatter);\n }\n\n /**\n * Parse a path into skill name and relative sub-path.\n * Paths look like `inline/<name>`, `inline/<name>/SKILL.md`, `inline/<name>/references/file.md`\n */\n #parsePath(inputPath: string): { skillName: string; subPath: string } | null {\n const prefix = 'inline/';\n if (!inputPath.startsWith(prefix)) return null;\n\n const rest = inputPath.slice(prefix.length);\n const slashIdx = rest.indexOf('/');\n if (slashIdx === -1) {\n return { skillName: rest, subPath: '' };\n }\n return { skillName: rest.slice(0, slashIdx), subPath: rest.slice(slashIdx + 1) };\n }\n\n #getSkill(inputPath: string): { skill: InlineSkill; subPath: string } | null {\n const parsed = this.#parsePath(inputPath);\n if (!parsed) return null;\n const skill = this.#skills.get(parsed.skillName);\n if (!skill) return null;\n return { skill, subPath: parsed.subPath };\n }\n\n async exists(path: string): Promise<boolean> {\n const result = this.#getSkill(path);\n if (!result) return false;\n\n const { skill, subPath } = result;\n\n // Root skill directory\n if (subPath === '') return true;\n // SKILL.md\n if (subPath === 'SKILL.md') return true;\n // references/ directory\n if (subPath === 'references') return (skill.references?.length ?? 0) > 0;\n // references/<file>\n if (subPath.startsWith('references/')) {\n const refPath = subPath.slice('references/'.length);\n return skill.references.includes(refPath);\n }\n return false;\n }\n\n async stat(path: string): Promise<SkillSourceStat> {\n const result = this.#getSkill(path);\n if (!result) {\n throw new Error(`ENOENT: no such file or directory: ${path}`);\n }\n\n const { skill, subPath } = result;\n const now = new Date();\n\n // Root skill directory\n if (subPath === '') {\n return { name: skill.name, type: 'directory', size: 0, createdAt: now, modifiedAt: now };\n }\n // SKILL.md\n if (subPath === 'SKILL.md') {\n const content = this.#skillMdCache.get(skill.name) ?? '';\n return {\n name: 'SKILL.md',\n type: 'file',\n size: Buffer.byteLength(content, 'utf-8'),\n createdAt: now,\n modifiedAt: now,\n mimeType: 'text/markdown',\n };\n }\n // references/ directory\n if (subPath === 'references') {\n return { name: 'references', type: 'directory', size: 0, createdAt: now, modifiedAt: now };\n }\n\n throw new Error(`ENOENT: no such file or directory: ${path}`);\n }\n\n async readFile(path: string): Promise<string | Buffer> {\n const result = this.#getSkill(path);\n if (!result) {\n throw new Error(`ENOENT: no such file or directory: ${path}`);\n }\n\n const { skill, subPath } = result;\n\n // SKILL.md\n if (subPath === 'SKILL.md') {\n return this.#skillMdCache.get(skill.name) ?? '';\n }\n\n // references/<file> — look up in the inline skill's bundled reference contents\n if (subPath.startsWith('references/')) {\n const refPath = subPath.slice('references/'.length);\n const content = skill.__referenceContents[refPath];\n if (content !== undefined) return content;\n }\n\n throw new Error(`ENOENT: no such file or directory: ${path}`);\n }\n\n async readdir(path: string): Promise<SkillSourceEntry[]> {\n const parsed = this.#parsePath(path);\n\n // Listing the root of all inline skills (when path is just the prefix base)\n // This shouldn't normally be called, but handle it gracefully\n if (!parsed) return [];\n\n const { skillName, subPath } = parsed;\n const skill = this.#skills.get(skillName);\n if (!skill) return [];\n\n // Root skill directory\n if (subPath === '') {\n const entries: SkillSourceEntry[] = [{ name: 'SKILL.md', type: 'file' }];\n if (skill.references.length > 0) {\n entries.push({ name: 'references', type: 'directory' });\n }\n return entries;\n }\n\n // references/ directory\n if (subPath === 'references') {\n return skill.references.map(ref => ({ name: ref, type: 'file' as const }));\n }\n\n return [];\n }\n}\n","/**\n * AgentSkillsResolver — resolves agent-level skills config into a WorkspaceSkills.\n *\n * Handles the split between path-based skills (resolved via LocalSkillSource)\n * and inline skills (served from InlineSkillSource), producing a single\n * WorkspaceSkillsImpl that the Agent can use for processor injection and tool creation.\n */\n\nimport type { RequestContext } from '../request-context';\nimport { LocalSkillSource } from '../workspace/skills/local-skill-source';\nimport type { SkillSource, SkillSourceEntry, SkillSourceStat } from '../workspace/skills/skill-source';\nimport type { WorkspaceSkills } from '../workspace/skills/types';\nimport { WorkspaceSkillsImpl } from '../workspace/skills/workspace-skills';\nimport { isInlineSkill } from './create-skill';\nimport { InlineSkillSource } from './inline-skill-source';\nimport type { InlineSkill, SkillInput } from './types';\n\n// =============================================================================\n// CompositeSkillSource\n// =============================================================================\n\n/**\n * Combines multiple SkillSources, routing by path prefix.\n * Inline skills use `inline:<name>` paths; everything else goes to LocalSkillSource.\n */\nclass CompositeSkillSource implements SkillSource {\n readonly #local: LocalSkillSource;\n readonly #inline: InlineSkillSource;\n\n constructor(local: LocalSkillSource, inline: InlineSkillSource) {\n this.#local = local;\n this.#inline = inline;\n }\n\n #route(path: string): SkillSource {\n return path.startsWith('inline/') ? this.#inline : this.#local;\n }\n\n exists(path: string): Promise<boolean> {\n return this.#route(path).exists(path);\n }\n\n stat(path: string): Promise<SkillSourceStat> {\n return this.#route(path).stat(path);\n }\n\n readFile(path: string): Promise<string | Buffer> {\n return this.#route(path).readFile(path);\n }\n\n readdir(path: string): Promise<SkillSourceEntry[]> {\n return this.#route(path).readdir(path);\n }\n\n async realpath(path: string): Promise<string> {\n const source = this.#route(path);\n return source.realpath ? source.realpath(path) : path;\n }\n}\n\n// =============================================================================\n// Resolver\n// =============================================================================\n\n/**\n * Resolve an array of SkillInput items into a WorkspaceSkills instance.\n *\n * @param skills - Array of path strings and/or inline skills\n * @returns A WorkspaceSkills implementation ready for use by the Agent\n */\nexport function resolveAgentSkills(skills: SkillInput[]): WorkspaceSkills {\n // Partition into inline skills and path strings\n const inlineSkills: InlineSkill[] = [];\n const pathSkills: string[] = [];\n\n for (const skill of skills) {\n if (isInlineSkill(skill)) {\n inlineSkills.push(skill);\n } else {\n pathSkills.push(skill);\n }\n }\n\n // Build the skill source(s)\n let source: SkillSource;\n\n // All skill paths that WorkspaceSkillsImpl will scan\n const skillPaths: string[] = [...pathSkills];\n\n if (inlineSkills.length > 0 && pathSkills.length > 0) {\n // Mixed: composite source\n const local = new LocalSkillSource();\n const inline = new InlineSkillSource(inlineSkills);\n source = new CompositeSkillSource(local, inline);\n // Add inline skill paths\n for (const skill of inlineSkills) {\n skillPaths.push(`inline/${skill.name}`);\n }\n } else if (inlineSkills.length > 0) {\n // Only inline skills\n const inline = new InlineSkillSource(inlineSkills);\n source = inline;\n for (const skill of inlineSkills) {\n skillPaths.push(`inline/${skill.name}`);\n }\n } else {\n // Only path-based skills\n source = new LocalSkillSource();\n }\n\n return new WorkspaceSkillsImpl({\n source,\n skills: skillPaths,\n validateOnLoad: true,\n });\n}\n\n/**\n * Merge two WorkspaceSkills instances by combining their skill lists.\n * Agent-level skills take precedence on name conflicts (returned first in list).\n */\nexport async function mergeWorkspaceSkills(\n agentSkills: WorkspaceSkills,\n workspaceSkills: WorkspaceSkills,\n): Promise<{ merged: WorkspaceSkills; agentSkillNames: Set<string> }> {\n // For now, we don't physically merge the implementations.\n // Instead, we create a MergedWorkspaceSkills wrapper that delegates to both.\n return {\n merged: new MergedWorkspaceSkills(agentSkills, workspaceSkills),\n agentSkillNames: new Set((await agentSkills.list()).map(s => s.name)),\n };\n}\n\n/**\n * A WorkspaceSkills wrapper that merges two skill sets.\n * Agent skills take precedence on name conflicts.\n */\nclass MergedWorkspaceSkills implements WorkspaceSkills {\n readonly #primary: WorkspaceSkills;\n readonly #secondary: WorkspaceSkills;\n\n constructor(primary: WorkspaceSkills, secondary: WorkspaceSkills) {\n this.#primary = primary;\n this.#secondary = secondary;\n }\n\n async list() {\n const primaryList = await this.#primary.list();\n const secondaryList = await this.#secondary.list();\n const primaryNames = new Set(primaryList.map(s => s.name));\n // Agent-level skills win on name conflicts\n return [...primaryList, ...secondaryList.filter(s => !primaryNames.has(s.name))];\n }\n\n async get(name: string) {\n const primary = await this.#primary.get(name);\n if (primary) return primary;\n return this.#secondary.get(name);\n }\n\n async has(name: string) {\n return (await this.#primary.has(name)) || (await this.#secondary.has(name));\n }\n\n async refresh() {\n await Promise.all([this.#primary.refresh(), this.#secondary.refresh()]);\n }\n\n async maybeRefresh(context?: { requestContext?: RequestContext }) {\n await Promise.all([this.#primary.maybeRefresh(context), this.#secondary.maybeRefresh(context)]);\n }\n\n async search(query: string, options?: Parameters<WorkspaceSkills['search']>[1]) {\n const [primaryResults, secondaryResults] = await Promise.all([\n this.#primary.search(query, options),\n this.#secondary.search(query, options),\n ]);\n // Combine and sort by score\n return [...primaryResults, ...secondaryResults].sort((a, b) => b.score - a.score);\n }\n\n async getReference(skillName: string, referencePath: string) {\n const primary = await this.#primary.getReference(skillName, referencePath);\n if (primary !== null) return primary;\n return this.#secondary.getReference(skillName, referencePath);\n }\n\n async getScript(skillName: string, scriptPath: string) {\n const primary = await this.#primary.getScript(skillName, scriptPath);\n if (primary !== null) return primary;\n return this.#secondary.getScript(skillName, scriptPath);\n }\n\n async getAsset(skillName: string, assetPath: string) {\n const primary = await this.#primary.getAsset(skillName, assetPath);\n if (primary !== null) return primary;\n return this.#secondary.getAsset(skillName, assetPath);\n }\n\n async listReferences(skillName: string) {\n const primary = await this.#primary.listReferences(skillName);\n if (primary.length > 0) return primary;\n return this.#secondary.listReferences(skillName);\n }\n\n async listScripts(skillName: string) {\n const primary = await this.#primary.listScripts(skillName);\n if (primary.length > 0) return primary;\n return this.#secondary.listScripts(skillName);\n }\n\n async listAssets(skillName: string) {\n const primary = await this.#primary.listAssets(skillName);\n if (primary.length > 0) return primary;\n return this.#secondary.listAssets(skillName);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,YAAY,OAAsC;CAChE,MAAM,EAAE,MAAM,aAAa,cAAc,SAAS,eAAe,UAAU,eAAe;CAG1F,MAAM,aAAaA,yBAAAA,sBACjB;EAAE;EAAM;EAAa;EAAS;EAAe,kBAAkB,MAAM;EAAmB;CAAS,GACjG,KAAA,GACA,YACF;CAEA,IAAI,CAAC,WAAW,OACd,MAAM,IAAI,MAAM,kBAAkB,KAAK,KAAK,WAAW,OAAO,KAAK,IAAI,GAAG;CAG5E,MAAM,gBAAgB,aAAa,OAAO,KAAK,UAAU,IAAI,CAAC;CAE9D,OAAO;EACL,UAAU;EACV,qBAAqB,cAAc,CAAC;EACpC;EACA;EACA;EACA;EACA;EACA,kBAAkB,MAAM;EACxB;EAEA,MAAM,UAAU;EAChB,QAAQ;GAAE,MAAM;GAAS,aAAa,UAAU;EAAO;EACvD,YAAY;EACZ,SAAS,CAAC;EACV,QAAQ,CAAC;CACX;AACF;;;;AAKA,SAAgB,cAAc,OAAsC;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,cAAc,SAAU,MAAsB,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