class PluginManager {
  plugins = /* @__PURE__ */ new Map();
  async register(plugin) {
    if (this.plugins.has(plugin.name)) {
      throw new Error(`Plugin ${plugin.name} already registered`);
    }
    this.plugins.set(plugin.name, plugin);
    if (plugin.initialize) {
      await plugin.initialize();
    }
  }
  async unregister(name) {
    const plugin = this.plugins.get(name);
    if (!plugin) return;
    if (plugin.shutdown) {
      await plugin.shutdown();
    }
    this.plugins.delete(name);
  }
  getPlugin(name) {
    return this.plugins.get(name);
  }
  getAllPlugins() {
    return Array.from(this.plugins.values());
  }
  // Get all commands from all plugins
  getAllCommands() {
    const commands = [];
    for (const plugin of this.plugins.values()) {
      if (plugin.registerCommands) {
        commands.push(...plugin.registerCommands());
      }
    }
    return commands;
  }
  // Get all tools from all plugins
  getAllTools() {
    const tools = [];
    for (const plugin of this.plugins.values()) {
      if (plugin.registerTools) {
        tools.push(...plugin.registerTools());
      }
    }
    return tools;
  }
  // Emit events to all plugins
  async emitFrameCreated(frame) {
    for (const plugin of this.plugins.values()) {
      if (plugin.onFrameCreated) {
        plugin.onFrameCreated(frame);
      }
    }
  }
  async emitContextSaved(context) {
    for (const plugin of this.plugins.values()) {
      if (plugin.onContextSaved) {
        plugin.onContextSaved(context);
      }
    }
  }
}
const pluginManager = new PluginManager();
export {
  PluginManager,
  pluginManager
};
//# sourceMappingURL=plugin-interface.js.map
