import { ContextHandlers } from "./context-handlers.js";
import { TaskHandlers } from "./task-handlers.js";
import { LinearHandlers } from "./linear-handlers.js";
import { TraceHandlers } from "./trace-handlers.js";
import { ContextHandlers as ContextHandlers2 } from "./context-handlers.js";
import { TaskHandlers as TaskHandlers2 } from "./task-handlers.js";
import { LinearHandlers as LinearHandlers2 } from "./linear-handlers.js";
import { TraceHandlers as TraceHandlers2 } from "./trace-handlers.js";
class MCPHandlerFactory {
  contextHandlers;
  taskHandlers;
  linearHandlers;
  traceHandlers;
  constructor(deps) {
    this.contextHandlers = new ContextHandlers2({
      frameManager: deps.frameManager,
      contextRetrieval: deps.contextRetrieval
    });
    this.taskHandlers = new TaskHandlers2({
      taskStore: deps.taskStore,
      projectId: deps.projectId
    });
    this.linearHandlers = new LinearHandlers2({
      linearAuthManager: deps.linearAuthManager,
      linearSync: deps.linearSync,
      taskStore: deps.taskStore
    });
    this.traceHandlers = new TraceHandlers2({
      traceDetector: deps.traceDetector,
      browserMCP: deps.browserMCP
    });
  }
  /**
   * Get handler for a specific tool
   */
  getHandler(toolName) {
    switch (toolName) {
      // Context handlers
      case "get_context":
        return this.contextHandlers.handleGetContext.bind(this.contextHandlers);
      case "add_decision":
        return this.contextHandlers.handleAddDecision.bind(this.contextHandlers);
      case "start_frame":
        return this.contextHandlers.handleStartFrame.bind(this.contextHandlers);
      case "close_frame":
        return this.contextHandlers.handleCloseFrame.bind(this.contextHandlers);
      case "add_anchor":
        return this.contextHandlers.handleAddAnchor.bind(this.contextHandlers);
      case "get_hot_stack":
        return this.contextHandlers.handleGetHotStack.bind(this.contextHandlers);
      // Task handlers
      case "create_task":
        return this.taskHandlers.handleCreateTask.bind(this.taskHandlers);
      case "update_task_status":
        return this.taskHandlers.handleUpdateTaskStatus.bind(this.taskHandlers);
      case "get_active_tasks":
        return this.taskHandlers.handleGetActiveTasks.bind(this.taskHandlers);
      case "get_task_metrics":
        return this.taskHandlers.handleGetTaskMetrics.bind(this.taskHandlers);
      case "add_task_dependency":
        return this.taskHandlers.handleAddTaskDependency.bind(this.taskHandlers);
      // Linear handlers
      case "linear_sync":
        return this.linearHandlers.handleLinearSync.bind(this.linearHandlers);
      case "linear_update_task":
        return this.linearHandlers.handleLinearUpdateTask.bind(this.linearHandlers);
      case "linear_get_tasks":
        return this.linearHandlers.handleLinearGetTasks.bind(this.linearHandlers);
      case "linear_status":
        return this.linearHandlers.handleLinearStatus.bind(this.linearHandlers);
      // Trace handlers
      case "get_traces":
        return this.traceHandlers.handleGetTraces.bind(this.traceHandlers);
      case "analyze_traces":
        return this.traceHandlers.handleAnalyzeTraces.bind(this.traceHandlers);
      case "start_browser_debug":
        return this.traceHandlers.handleStartBrowserDebug.bind(this.traceHandlers);
      case "take_screenshot":
        return this.traceHandlers.handleTakeScreenshot.bind(this.traceHandlers);
      case "execute_script":
        return this.traceHandlers.handleExecuteScript.bind(this.traceHandlers);
      case "stop_browser_debug":
        return this.traceHandlers.handleStopBrowserDebug.bind(this.traceHandlers);
      default:
        throw new Error(`Unknown tool: ${toolName}`);
    }
  }
  /**
   * Get all available tool names
   */
  getAvailableTools() {
    return [
      // Context tools
      "get_context",
      "add_decision",
      "start_frame",
      "close_frame",
      "add_anchor",
      "get_hot_stack",
      // Task tools
      "create_task",
      "update_task_status",
      "get_active_tasks",
      "get_task_metrics",
      "add_task_dependency",
      // Linear tools
      "linear_sync",
      "linear_update_task",
      "linear_get_tasks",
      "linear_status",
      // Trace tools
      "get_traces",
      "analyze_traces",
      "start_browser_debug",
      "take_screenshot",
      "execute_script",
      "stop_browser_debug"
    ];
  }
  /**
   * Check if a tool exists
   */
  hasHandler(toolName) {
    return this.getAvailableTools().includes(toolName);
  }
}
export {
  ContextHandlers,
  LinearHandlers,
  MCPHandlerFactory,
  TaskHandlers,
  TraceHandlers
};
//# sourceMappingURL=index.js.map
