UNPKG

@mastra/core

Version:

Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.

73 lines 2.89 kB
/** * WorkspaceSkills - Skills implementation. * * Provides discovery and search operations for skills stored * in skills paths. All operations are async. */ import type { IndexDocument, SearchResult } from '../search/index.js'; import type { SkillSource as SkillSourceInterface } from './skill-source.js'; import type { Skill, SkillMetadata, SkillSearchResult, SkillSearchOptions, WorkspaceSkills, SkillsResolver, SkillsContext } from './types.js'; /** * Minimal search engine interface - only the methods we actually use. * This allows both the real SearchEngine and test mocks to be used. */ interface SkillSearchEngine { index(doc: IndexDocument): Promise<void>; remove?(id: string): Promise<void>; search(query: string, options?: { topK?: number; minScore?: number; mode?: 'bm25' | 'vector' | 'hybrid'; }): Promise<SearchResult[]>; clear(): void; } /** * Configuration for WorkspaceSkillsImpl */ export interface WorkspaceSkillsImplConfig { /** * Source for loading skills. */ source: SkillSourceInterface; /** * Paths to scan for skills. * Can be a static array or a function that returns paths based on context. */ skills: SkillsResolver; /** Search engine for skill search (optional) */ searchEngine?: SkillSearchEngine; /** Validate skills on load (default: true) */ validateOnLoad?: boolean; /** * Check SKILL.md file mtime in addition to directory mtime for staleness detection. * Enables detection of in-place file edits (e.g., fixing validation errors). * Increases stat calls - recommended for local development only. * Default: false */ checkSkillFileMtime?: boolean; } /** * Implementation of WorkspaceSkills interface. */ export declare class WorkspaceSkillsImpl implements WorkspaceSkills { #private; static readonly GLOB_RESOLVE_INTERVAL = 5000; static readonly STALENESS_CHECK_COOLDOWN = 2000; constructor(config: WorkspaceSkillsImplConfig); list(): Promise<SkillMetadata[]>; get(name: string): Promise<Skill | null>; has(name: string): Promise<boolean>; refresh(): Promise<void>; maybeRefresh(context?: SkillsContext): Promise<void>; addSkill(skillPath: string): Promise<void>; removeSkill(skillName: string): Promise<void>; search(query: string, options?: SkillSearchOptions): Promise<SkillSearchResult[]>; getReference(skillName: string, referencePath: string): Promise<string | null>; getScript(skillName: string, scriptPath: string): Promise<string | null>; getAsset(skillName: string, assetPath: string): Promise<Buffer | null>; listReferences(skillName: string): Promise<string[]>; listScripts(skillName: string): Promise<string[]>; listAssets(skillName: string): Promise<string[]>; } export {}; //# sourceMappingURL=workspace-skills.d.ts.map