/**
 * UNIVERSAL CAPABILITY FRAMEWORK
 *
 * A unified framework for all AGI capabilities that promotes code reuse,
 * consistent patterns, and cross-module integration.
 *
 * KEY PRINCIPLES:
 * 1. Single Source of Truth - Common utilities used by all capabilities
 * 2. Dependency Injection - Capabilities declare dependencies
 * 3. Event-Driven Architecture - Cross-module communication via events
 * 4. Pluggable Architecture - Capabilities can be registered/unregistered at runtime
 * 5. Type Safety - Full TypeScript support with generic types
 */
import type { CapabilityContribution, CapabilityContext, CapabilityModule } from '../runtime/agentHost.js';
import type { ToolSuite, ToolDefinition } from '../core/toolRuntime.js';
import { EventEmitter } from 'events';
export interface UniversalCapabilityConfig {
    /** Root directory for framework operations */
    rootDir: string;
    /** Enable debug logging */
    debug: boolean;
    /** Enable cross-capability events */
    enableEvents: boolean;
    /** Enable dependency resolution */
    enableDependencyResolution: boolean;
    /** Shared data directory */
    sharedDataDir: string;
    /** Plugin discovery patterns */
    pluginPatterns: string[];
}
export interface CapabilityMetadata {
    id: string;
    version: string;
    description: string;
    author: string;
    dependencies: string[];
    provides: string[];
    requires: string[];
    category: string;
    tags: string[];
    configurationSchema?: Record<string, any>;
}
export interface CapabilityRegistration {
    module: CapabilityModule;
    metadata: CapabilityMetadata;
    instance: any;
    status: 'registered' | 'active' | 'error' | 'disabled';
    dependencies: string[];
    dependents: string[];
}
export interface UniversalFrameworkEvent {
    type: string;
    source: string;
    timestamp: number;
    data: any;
    correlationId?: string;
}
export interface DependencyGraph {
    nodes: Map<string, CapabilityRegistration>;
    edges: Map<string, Set<string>>;
    topologicalOrder: string[];
    hasCycles: boolean;
}
export declare class UniversalCapabilityFramework extends EventEmitter {
    private config;
    private capabilities;
    private dependencyGraph;
    private sharedUtilities;
    private eventBus;
    private contextManager;
    private toolRegistry;
    constructor(config?: Partial<UniversalCapabilityConfig>);
    private initializeFramework;
    /**
     * Register a capability with the framework
     */
    registerCapability(module: CapabilityModule, metadata: CapabilityMetadata): Promise<CapabilityRegistration>;
    /**
     * Activate a capability (resolve dependencies and initialize)
     */
    activateCapability(capabilityId: string): Promise<CapabilityRegistration>;
    /**
     * Activate all dependencies for a capability
     */
    private activateDependencies;
    /**
     * Get a capability instance
     */
    getCapability<T = any>(capabilityId: string): T | null;
    /**
     * Execute a cross-capability operation
     */
    executeOperation(operation: string, parameters: Record<string, any>, capabilities: string[]): Promise<any>;
    /**
     * Update dependency graph
     */
    private updateDependencyGraph;
    private detectCycles;
    private topologicalSort;
    /**
     * Logging utility
     */
    private log;
    /**
     * Get framework configuration
     */
    getConfig(): UniversalCapabilityConfig;
    /**
     * List all registered capabilities
     */
    listCapabilities(): CapabilityRegistration[];
    /**
     * Get dependency graph
     */
    getDependencyGraph(): DependencyGraph;
    /**
     * Get shared utilities
     */
    getSharedUtilities(): SharedUniversalUtilities;
    /**
     * Get event bus
     */
    getEventBus(): EventEmitter;
    /**
     * Get tool registry
     */
    getToolRegistry(): ToolRegistry;
}
export declare class SharedUniversalUtilities {
    private config;
    constructor(config: UniversalCapabilityConfig);
    /**
     * Generate unique operation ID
     */
    generateOperationId(prefix?: string): string;
    /**
     * Create shared data directory for operation
     */
    createOperationDir(operationId: string): string;
    /**
     * Save evidence/data to shared storage
     */
    saveToSharedStorage(operationId: string, fileName: string, data: any): string;
    /**
     * Read from shared storage
     */
    readFromSharedStorage(operationId: string, fileName: string): string | null;
    /**
     * Merge multiple objects (deep merge)
     */
    deepMerge<T extends Record<string, any>>(target: T, ...sources: Partial<T>[]): T;
    /**
     * Validate configuration against schema
     */
    validateConfig(config: any, schema: Record<string, any>): {
        valid: boolean;
        errors: string[];
    };
    /**
     * Execute with retry logic
     */
    executeWithRetry<T>(operation: () => Promise<T>, maxRetries?: number, delay?: number): Promise<T>;
    /**
     * Create standardized tool definition
     */
    createToolDefinition<T extends Record<string, unknown>>(name: string, description: string, parameters: any, handler: (args: T) => Promise<string> | string): ToolDefinition<T>;
}
export declare class ContextManager {
    private contexts;
    private defaultContext;
    /**
     * Set context value
     */
    setContext(key: string, value: any): void;
    /**
     * Get context value
     */
    getContext<T = any>(key: string): T | undefined;
    /**
     * Clear context
     */
    clearContext(key: string): boolean;
    /**
     * Get all contexts
     */
    getAllContexts(): Record<string, any>;
    /**
     * Save context to file
     */
    saveContexts(filePath: string): void;
    /**
     * Load contexts from file
     */
    loadContexts(filePath: string): void;
}
export declare class ToolRegistry {
    private tools;
    private toolSuites;
    /**
     * Register a tool
     */
    registerTool(tool: ToolDefinition): void;
    /**
     * Register a tool suite
     */
    registerToolSuite(suite: ToolSuite): void;
    /**
     * Get a tool by name
     */
    getTool<T extends Record<string, unknown>>(name: string): ToolDefinition<T> | undefined;
    /**
     * Get a tool suite by ID
     */
    getToolSuite(id: string): ToolSuite | undefined;
    /**
     * List all tools
     */
    listTools(): ToolDefinition[];
    /**
     * List all tool suites
     */
    listToolSuites(): ToolSuite[];
    /**
     * Search tools by criteria
     */
    searchTools(criteria: (tool: ToolDefinition) => boolean): ToolDefinition[];
}
export declare abstract class UniversalCapabilityModule implements CapabilityModule {
    abstract readonly id: string;
    abstract readonly metadata: CapabilityMetadata;
    protected framework: UniversalCapabilityFramework;
    protected utilities: SharedUniversalUtilities;
    protected contextManager: ContextManager;
    protected toolRegistry: ToolRegistry;
    protected config: Record<string, any>;
    constructor(framework: UniversalCapabilityFramework, config?: Record<string, any>);
    /**
     * Abstract method - must be implemented by subclasses
     */
    abstract create(context: CapabilityContext): Promise<CapabilityContribution | CapabilityContribution[] | null | undefined>;
    /**
     * Initialize capability (called after constructor)
     */
    initialize(): Promise<void>;
    /**
     * Cleanup capability (called before disposal)
     */
    cleanup(): Promise<void>;
    /**
     * Execute an operation (common interface for all capabilities)
     */
    execute(params: {
        operation: string;
        parameters: Record<string, any>;
        operationId?: string;
    }): Promise<any>;
    /**
     * Validate configuration
     */
    validateConfig(schema: Record<string, any>): {
        valid: boolean;
        errors: string[];
    };
    /**
     * Log with capability context
     */
    protected log(level: 'info' | 'warn' | 'error', message: string, data?: any): void;
    /**
     * Emit framework event
     */
    protected emitEvent(type: string, data: any): void;
    /**
     * Create fallback file tool for filesystem capability
     */
    protected createFallbackFileTool(): ToolDefinition;
}
export declare class UniversalCapabilityFactory {
    private static capabilityRegistry;
    /**
     * Register a capability class
     */
    static registerCapability(id: string, constructor: new (framework: UniversalCapabilityFramework, config: any) => UniversalCapabilityModule): void;
    /**
     * Create capability instance
     */
    static createCapability(id: string, framework: UniversalCapabilityFramework, config?: any): UniversalCapabilityModule | null;
    /**
     * List all registered capability types
     */
    static listCapabilityTypes(): string[];
}
/**
 * Universal Filesystem Capability
 */
export declare class UniversalFilesystemCapability extends UniversalCapabilityModule {
    readonly id = "capability.universal-filesystem";
    readonly metadata: CapabilityMetadata;
    create(context: CapabilityContext): Promise<CapabilityContribution>;
    execute(params: {
        operation: string;
        parameters: Record<string, any>;
        operationId?: string;
    }): Promise<any>;
    private readFile;
    private writeFile;
    private listDirectory;
    private searchFiles;
}
/**
 * Universal Bash Capability
 */
export declare class UniversalBashCapability extends UniversalCapabilityModule {
    readonly id = "capability.universal-bash";
    readonly metadata: CapabilityMetadata;
    create(context: CapabilityContext): Promise<CapabilityContribution>;
    private createFallbackBashTool;
    execute(params: {
        operation: string;
        parameters: Record<string, any>;
        operationId?: string;
    }): Promise<any>;
}
/**
 * Universal Search Capability
 */
export declare class UniversalSearchCapability extends UniversalCapabilityModule {
    readonly id = "capability.universal-search";
    readonly metadata: CapabilityMetadata;
    create(context: CapabilityContext): Promise<CapabilityContribution>;
    private createFallbackSearchTool;
    execute(params: {
        operation: string;
        parameters: Record<string, any>;
        operationId?: string;
    }): Promise<any>;
}
/**
 * Universal Edit Capability
 */
export declare class UniversalEditCapability extends UniversalCapabilityModule {
    readonly id = "capability.universal-edit";
    readonly metadata: CapabilityMetadata;
    create(context: CapabilityContext): Promise<CapabilityContribution>;
    private createFallbackEditTool;
    execute(params: {
        operation: string;
        parameters: Record<string, any>;
        operationId?: string;
    }): Promise<any>;
}
export default UniversalCapabilityFramework;
//# sourceMappingURL=universalCapabilityFramework.d.ts.map