/**
 * Plugin System - Root Index
 *
 * Aggregates all plugin functionality for easy import.
 *
 * Principal Investigator: Bo Shang
 * Framework: agi-cli
 */
// Re-export tool plugin system
export { registerToolPlugin, unregisterToolPlugin, listRegisteredToolPlugins, instantiateToolPlugins, } from './tools/index.js';
export { registerDefaultNodeToolPlugins } from './tools/nodeDefaults.js';
// Track loaded plugins
const loadedPlugins = new Map();
/**
 * Register a plugin as loaded
 */
export function markPluginLoaded(plugin) {
    loadedPlugins.set(plugin.id, plugin);
}
/**
 * Get a loaded plugin by ID
 */
export function getLoadedPlugin(id) {
    return loadedPlugins.get(id);
}
/**
 * List all loaded plugins
 */
export function listLoadedPlugins() {
    return Array.from(loadedPlugins.values());
}
/**
 * List available plugins (combines loaded + builtin)
 */
export function listAvailablePlugins() {
    const available = new Set();
    for (const id of BUILTIN_PLUGINS) {
        available.add(id);
    }
    for (const id of loadedPlugins.keys()) {
        available.add(id);
    }
    return Array.from(available);
}
/**
 * Get all plugin tool suites
 */
export function getAllPluginToolSuites() {
    return listLoadedPlugins().filter((p) => p.enabled);
}
/**
 * Load a plugin by ID
 */
export async function loadPlugin(id) {
    // Check if already loaded
    const existing = loadedPlugins.get(id);
    if (existing) {
        return existing;
    }
    // Check if it's a builtin plugin
    if (!BUILTIN_PLUGINS.includes(id)) {
        return null;
    }
    // Create a loaded plugin entry
    const plugin = {
        id,
        name: id.replace(/-/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()),
        version: '1.0.0',
        enabled: true,
    };
    loadedPlugins.set(id, plugin);
    return plugin;
}
/**
 * Get plugin IDs from command line flags
 */
export function getPluginIdsFromFlags(flags) {
    const ids = new Set();
    // Convenience flags
    if (flags['allPlugins']) {
        BUILTIN_PLUGINS.forEach((id) => ids.add(id));
    }
    if (flags['coding']) {
        ids.add('tool.enhanced-git');
    }
    for (const [flag, enabled] of Object.entries(flags)) {
        if (enabled && BUILTIN_PLUGINS.includes(flag)) {
            ids.add(flag);
        }
    }
    return Array.from(ids);
}
/**
 * Builtin plugin identifiers
 */
export const BUILTIN_PLUGINS = [
    'tool.filesystem.local',
    'tool.bash.local',
    'tool.search.local',
    'tool.edit',
    'tool.enhanced-git',
    'tool.tao',
    'tool.dependency-management',
];
//# sourceMappingURL=index.js.map