import type { OrchestratorPlugin } from "../types"
import type { RegisteredPlugin } from "@racletteCore"

// Global state management
export const registeredPlugins: { [key: string]: RegisteredPlugin } = {}

export const pluginPathMapping: { [path: string]: string } = {}

export const pluginDataTypes: { [key: string]: any } = {}

export const orchestratorPlugins: OrchestratorPlugin[] = []

export const pluginReadOperations: { [key: string]: any } = {}

// State manipulation helpers
export const addRegisteredPlugin = (
  key: string,
  plugin: RegisteredPlugin,
): void => {
  registeredPlugins[key] = plugin
}

export const getRegisteredPlugin = (
  key: string,
): RegisteredPlugin | undefined => {
  return registeredPlugins[key]
}

export const addPluginPathMapping = (path: string, key: string): void => {
  pluginPathMapping[path] = key
}

export const addPluginDataType = (key: string, dataType: any): void => {
  pluginDataTypes[key] = dataType
}

export const addOrchestratorPlugin = (plugin: OrchestratorPlugin): void => {
  orchestratorPlugins.push(plugin)
}

export const addPluginReadOperation = (key: string, operation: any): any => {
  return (pluginReadOperations[key] = operation)
}
