@craftapit/tester
Version:
A focused, LLM-powered testing framework for natural language test scenarios
126 lines (125 loc) • 3.26 kB
TypeScript
import { AddonCapability, CapabilityFeedback, CapabilityRegistry as ICapabilityRegistry } from '../types/addon';
import { BaseAdapter } from '../adapters/BaseAdapter';
import { LLMAdapter } from '../adapters/LLMAdapter';
/**
* Registry for addon capabilities with vector-based caching
*/
export declare class CapabilityRegistry implements ICapabilityRegistry {
/**
* Map of adapter types to adapter instances
*/
private adapters;
/**
* Map of capability names to capability definitions
*/
private capabilities;
/**
* LLM adapter for resolving capabilities
*/
private llmAdapter;
/**
* Cache of feedback entries
*/
private feedback;
/**
* Vector store for context action caching
*/
private vectorStore;
/**
* Embedding utility
*/
private embedder;
/**
* Cache file path for persisting vectorized actions
*/
private cacheFilePath;
/**
* Whether vectorized caching is enabled
*/
private cachingEnabled;
constructor(options?: {
cachingEnabled?: boolean;
cacheFilePath?: string;
embeddingDimension?: number;
});
/**
* Set the LLM adapter for capability resolution
*/
setLLMAdapter(llmAdapter: LLMAdapter): void;
/**
* Register an adapter
*/
registerAdapter(type: string, adapter: BaseAdapter): void;
/**
* Get an adapter by type
*/
getAdapter<T extends BaseAdapter>(type: string): T | null;
/**
* Register a capability
*/
registerCapability(capability: AddonCapability): void;
/**
* Get a capability by name
*/
getCapability(name: string): AddonCapability | null;
/**
* Get all capabilities
*/
getAllCapabilities(): AddonCapability[];
/**
* Get capability context for LLM
*/
getCapabilityContext(): string;
/**
* Find capability for action using LLM or vector cache
*/
findCapabilityForAction(description: string): Promise<{
capability: AddonCapability;
parameters: any[];
confidence: number;
} | null>;
/**
* Find a cached capability match for the given description
*/
private findCachedCapability;
/**
* Cache a capability resolution result
*/
private cacheCapabilityResolution;
/**
* Build prompt for capability resolution
*/
private buildCapabilityResolutionPrompt;
/**
* Parse LLM response for capability resolution
*/
private parseCapabilityResolutionResponse;
/**
* Execute a capability
*/
executeCapability(name: string, parameters: any[]): Promise<any>;
/**
* Provide feedback on a capability resolution
*/
provideFeedback(feedback: CapabilityFeedback): Promise<void>;
/**
* Clean up incorrect capability selections by removing similar cache entries
*/
private cleanupIncorrectEntries;
/**
* Get feedback for analysis
*/
getFeedback(): CapabilityFeedback[];
/**
* Save the cache to disk
*/
private saveCache;
/**
* Load the cache from disk
*/
private loadCache;
/**
* Clear the cache
*/
clearCache(): void;
}