/**
 * AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
 *
 * Generated by: scripts/generate-tool-registry.ts
 * Generated at: 2026-05-21T10:36:13.172Z
 *
 * To regenerate: npm run generate:tools
 */

import type { ToolFunction } from '../domain/entities/Tool.js';

import { executeJavaScript } from './code/executeJavaScript.js';
import { customToolDelete } from './custom-tools/customToolDelete.js';
import { customToolDraft } from './custom-tools/customToolDraft.js';
import { customToolList } from './custom-tools/customToolList.js';
import { customToolLoad } from './custom-tools/customToolLoad.js';
import { customToolSave } from './custom-tools/customToolSave.js';
import { customToolTest } from './custom-tools/customToolTest.js';
import { desktopGetCursor } from './desktop/getCursor.js';
import { desktopGetScreenSize } from './desktop/getScreenSize.js';
import { desktopKeyboardKey } from './desktop/keyboardKey.js';
import { desktopKeyboardType } from './desktop/keyboardType.js';
import { desktopMouseClick } from './desktop/mouseClick.js';
import { desktopMouseDrag } from './desktop/mouseDrag.js';
import { desktopMouseMove } from './desktop/mouseMove.js';
import { desktopMouseScroll } from './desktop/mouseScroll.js';
import { desktopScreenshot } from './desktop/screenshot.js';
import { desktopWindowFocus } from './desktop/windowFocus.js';
import { desktopWindowList } from './desktop/windowList.js';
import { editFile } from './filesystem/editFile.js';
import { glob } from './filesystem/glob.js';
import { grep } from './filesystem/grep.js';
import { listDirectory } from './filesystem/listDirectory.js';
import { readFile } from './filesystem/readFile.js';
import { writeFile } from './filesystem/writeFile.js';
import { jsonManipulator } from './json/jsonManipulator.js';
import { generateRoutine } from './routines/generateRoutine.js';
import { routineDelete } from './routines/routineDelete.js';
import { routineGet } from './routines/routineGet.js';
import { routineGetTaskSteps } from './routines/routineGetTaskSteps.js';
import { routineList } from './routines/routineList.js';
import { routineListExecutions } from './routines/routineListExecutions.js';
import { routineUpdate } from './routines/routineUpdate.js';
import { routineUpdateTask } from './routines/routineUpdateTask.js';
import { bash } from './shell/bash.js';
import { bgProcessKill } from './shell/bgProcessKill.js';
import { bgProcessList } from './shell/bgProcessList.js';
import { bgProcessOutput } from './shell/bgProcessOutput.js';
import { devServer } from './shell/devServer.js';
import { webFetch } from './web/webFetch.js';

/** Tool category for grouping */
export type ToolCategory = 'filesystem' | 'shell' | 'web' | 'code' | 'json' | 'connector' | 'desktop' | 'custom-tools' | 'routines' | 'other';

/** Metadata for a tool in the registry */
export interface ToolRegistryEntry {
  /** Tool name (matches definition.function.name) */
  name: string;
  /** Export variable name */
  exportName: string;
  /** Human-readable display name */
  displayName: string;
  /** Category for grouping */
  category: ToolCategory;
  /** Brief description */
  description: string;
  /** The actual tool function */
  tool: ToolFunction;
  /** Whether this tool is safe without explicit approval */
  safeByDefault: boolean;
  /** Whether this tool requires a connector */
  requiresConnector?: boolean;
  /** Supported connector service types (if requiresConnector) */
  connectorServiceTypes?: string[];
}

/** Complete registry of all built-in tools */
export const toolRegistry: ToolRegistryEntry[] = [
  {
    name: 'execute_javascript',
    exportName: 'executeJavaScript',
    displayName: 'Execute Javascript',
    category: 'code',
    description: "Execute JavaScript code in a secure sandbox with authenticated API access via connectors.",
    tool: executeJavaScript,
    safeByDefault: false,
  },
  {
    name: 'custom_tool_delete',
    exportName: 'customToolDelete',
    displayName: 'Custom Tool Delete',
    category: 'custom-tools',
    description: "Delete a custom tool from persistent storage.",
    tool: customToolDelete,
    safeByDefault: false,
  },
  {
    name: 'custom_tool_draft',
    exportName: 'customToolDraft',
    displayName: 'Custom Tool Draft',
    category: 'custom-tools',
    description: "Validate a draft custom tool definition. Checks name format, schema structure, and code syntax.",
    tool: customToolDraft,
    safeByDefault: true,
  },
  {
    name: 'custom_tool_list',
    exportName: 'customToolList',
    displayName: 'Custom Tool List',
    category: 'custom-tools',
    description: "List saved custom tools from persistent storage. Supports filtering by search text, tags, and category.",
    tool: customToolList,
    safeByDefault: true,
  },
  {
    name: 'custom_tool_load',
    exportName: 'customToolLoad',
    displayName: 'Custom Tool Load',
    category: 'custom-tools',
    description: "Load a full custom tool definition from storage (including code).",
    tool: customToolLoad,
    safeByDefault: true,
  },
  {
    name: 'custom_tool_save',
    exportName: 'customToolSave',
    displayName: 'Custom Tool Save',
    category: 'custom-tools',
    description: "Save a custom tool definition to persistent storage.",
    tool: customToolSave,
    safeByDefault: false,
  },
  {
    name: 'custom_tool_test',
    exportName: 'customToolTest',
    displayName: 'Custom Tool Test',
    category: 'custom-tools',
    description: "Test custom tool code by executing it in the VM sandbox with provided test input.",
    tool: customToolTest,
    safeByDefault: false,
  },
  {
    name: 'desktop_get_cursor',
    exportName: 'desktopGetCursor',
    displayName: 'Desktop Get Cursor',
    category: 'desktop',
    description: "Get the current mouse cursor position in screen pixel coordinates (same space as the screenshot and mouseClick/mouseMove).",
    tool: desktopGetCursor,
    safeByDefault: false,
  },
  {
    name: 'desktop_get_screen_size',
    exportName: 'desktopGetScreenSize',
    displayName: 'Desktop Get Screen Size',
    category: 'desktop',
    description: "Get the screen dimensions. Returns physical pixel size (screenshot space), logical size (OS coordinates), and the scale factor (e.g., 2.0 on Retina displays). All desktop tool coordinates use physical",
    tool: desktopGetScreenSize,
    safeByDefault: false,
  },
  {
    name: 'desktop_keyboard_key',
    exportName: 'desktopKeyboardKey',
    displayName: 'Desktop Keyboard Key',
    category: 'desktop',
    description: "Press a keyboard shortcut or special key. Use \"+\" to combine keys (e.g., \"ctrl+c\", \"cmd+shift+s\", \"enter\", \"tab\", \"escape\"). Modifiers: ctrl, cmd/command, alt/option, shift. Special keys: enter, tab, ",
    tool: desktopKeyboardKey,
    safeByDefault: false,
  },
  {
    name: 'desktop_keyboard_type',
    exportName: 'desktopKeyboardType',
    displayName: 'Desktop Keyboard Type',
    category: 'desktop',
    description: "Type text using the keyboard. Each character is typed as a keypress. Use this for entering text into focused input fields.",
    tool: desktopKeyboardType,
    safeByDefault: false,
  },
  {
    name: 'desktop_mouse_click',
    exportName: 'desktopMouseClick',
    displayName: 'Desktop Mouse Click',
    category: 'desktop',
    description: "Click the mouse at the specified position or at the current cursor position. Supports left/right/middle button and single/double/triple click.",
    tool: desktopMouseClick,
    safeByDefault: false,
  },
  {
    name: 'desktop_mouse_drag',
    exportName: 'desktopMouseDrag',
    displayName: 'Desktop Mouse Drag',
    category: 'desktop',
    description: "Drag the mouse from one position to another. Presses the button at the start position, moves to the end position, then releases.",
    tool: desktopMouseDrag,
    safeByDefault: false,
  },
  {
    name: 'desktop_mouse_move',
    exportName: 'desktopMouseMove',
    displayName: 'Desktop Mouse Move',
    category: 'desktop',
    description: "Move the mouse cursor to the specified (x, y) position. Coordinates are in screen pixel space (full screen). Returns the actual cursor position after the move for verification.",
    tool: desktopMouseMove,
    safeByDefault: false,
  },
  {
    name: 'desktop_mouse_scroll',
    exportName: 'desktopMouseScroll',
    displayName: 'Desktop Mouse Scroll',
    category: 'desktop',
    description: "Scroll the mouse wheel. Positive deltaY scrolls down, negative scrolls up. Positive deltaX scrolls right, negative scrolls left. Optionally specify position to scroll at.",
    tool: desktopMouseScroll,
    safeByDefault: false,
  },
  {
    name: 'desktop_screenshot',
    exportName: 'desktopScreenshot',
    displayName: 'Desktop Screenshot',
    category: 'desktop',
    description: "Take a screenshot of the entire screen or a specific region. Returns the screenshot image for visual analysis. The image pixel coordinates match the coordinate space used by desktop_mouse_click / desk",
    tool: desktopScreenshot,
    safeByDefault: false,
  },
  {
    name: 'desktop_window_focus',
    exportName: 'desktopWindowFocus',
    displayName: 'Desktop Window Focus',
    category: 'desktop',
    description: "Focus (bring to front) a window by its ID. Use desktop_window_list to get available window IDs.",
    tool: desktopWindowFocus,
    safeByDefault: false,
  },
  {
    name: 'desktop_window_list',
    exportName: 'desktopWindowList',
    displayName: 'Desktop Window List',
    category: 'desktop',
    description: "List all visible windows on the desktop. Returns window IDs, titles, application names, and bounds. Use the window ID with desktop_window_focus to bring a window to the foreground.",
    tool: desktopWindowList,
    safeByDefault: false,
  },
  {
    name: 'edit_file',
    exportName: 'editFile',
    displayName: 'Edit File',
    category: 'filesystem',
    description: "Perform exact string replacements in files.",
    tool: editFile,
    safeByDefault: false,
  },
  {
    name: 'glob',
    exportName: 'glob',
    displayName: 'Glob',
    category: 'filesystem',
    description: "Fast file pattern matching tool that finds files by name patterns.",
    tool: glob,
    safeByDefault: true,
  },
  {
    name: 'grep',
    exportName: 'grep',
    displayName: 'Grep',
    category: 'filesystem',
    description: "A powerful search tool for finding content within files.",
    tool: grep,
    safeByDefault: true,
  },
  {
    name: 'list_directory',
    exportName: 'listDirectory',
    displayName: 'List Directory',
    category: 'filesystem',
    description: "List the contents of a directory on the local filesystem.",
    tool: listDirectory,
    safeByDefault: true,
  },
  {
    name: 'read_file',
    exportName: 'readFile',
    displayName: 'Read File',
    category: 'filesystem',
    description: "Read content from a file on the local filesystem. Supports text files AND binary document formats — PDF, DOCX, PPTX, XLSX, ODS, ODT, ODP, and images (PNG, JPG, GIF, WEBP) are automatically converted t",
    tool: readFile,
    safeByDefault: true,
  },
  {
    name: 'write_file',
    exportName: 'writeFile',
    displayName: 'Write File',
    category: 'filesystem',
    description: "Write content to a file on the local filesystem.",
    tool: writeFile,
    safeByDefault: false,
  },
  {
    name: 'json_manipulate',
    exportName: 'jsonManipulator',
    displayName: 'Json Manipulate',
    category: 'json',
    description: "Manipulate JSON objects by deleting, adding, or replacing fields at any depth.",
    tool: jsonManipulator,
    safeByDefault: true,
  },
  {
    name: 'generate_routine',
    exportName: 'generateRoutine',
    displayName: 'Generate Routine',
    category: 'routines',
    description: "Complete routine definition input",
    tool: generateRoutine,
    safeByDefault: false,
  },
  {
    name: 'routine_delete',
    exportName: 'routineDelete',
    displayName: 'Routine Delete',
    category: 'routines',
    description: "Permanently delete a routine definition. Past execution records are preserved, but any schedules or systems still referencing this routine ID will fail at runtime. Confirm with the user before calling",
    tool: routineDelete,
    safeByDefault: false,
  },
  {
    name: 'routine_get',
    exportName: 'routineGet',
    displayName: 'Routine Get',
    category: 'routines',
    description: "Retrieve a routine definition by ID or by name search. Returns the full routine structure including tasks, parameters, and metadata.",
    tool: routineGet,
    safeByDefault: false,
  },
  {
    name: 'routine_get_task_steps',
    exportName: 'routineGetTaskSteps',
    displayName: 'Routine Get Task Steps',
    category: 'routines',
    description: "Get step-level execution detail for a routine execution. Filter by task name, phase, or step types.\\n\\n",
    tool: routineGetTaskSteps,
    safeByDefault: false,
  },
  {
    name: 'routine_list',
    exportName: 'routineList',
    displayName: 'Routine List',
    category: 'routines',
    description: "List routine definitions accessible to the caller. Returns slim summary entries (id, name, description, version, author, tags, task count, parameter names) — fetch the full structure with routine_get.",
    tool: routineList,
    safeByDefault: false,
  },
  {
    name: 'routine_list_executions',
    exportName: 'routineListExecutions',
    displayName: 'Routine List Executions',
    category: 'routines',
    description: "List execution records for a routine. Returns summaries of past and current executions including status, timing, and per-task results.",
    tool: routineListExecutions,
    safeByDefault: false,
  },
  {
    name: 'routine_update',
    exportName: 'routineUpdate',
    displayName: 'Routine Update',
    category: 'routines',
    description: "Update an existing routine definition.",
    tool: routineUpdate,
    safeByDefault: false,
  },
  {
    name: 'routine_update_task',
    exportName: 'routineUpdateTask',
    displayName: 'Routine Update Task',
    category: 'routines',
    description: "Update a specific task within an existing routine definition. Validates the updated routine before saving.",
    tool: routineUpdateTask,
    safeByDefault: false,
  },
  {
    name: 'bash',
    exportName: 'bash',
    displayName: 'Bash',
    category: 'shell',
    description: "Execute shell commands with optional timeout.",
    tool: bash,
    safeByDefault: false,
  },
  {
    name: 'bg_process_kill',
    exportName: 'bgProcessKill',
    displayName: 'Bg Process Kill',
    category: 'shell',
    description: "Stop a running background process. Sends SIGTERM for graceful shutdown (allows the process to clean up), then SIGKILL after 3 seconds if it hasn't exited. Kills the entire process tree — so \"npm run d",
    tool: bgProcessKill,
    safeByDefault: false,
  },
  {
    name: 'bg_process_list',
    exportName: 'bgProcessList',
    displayName: 'Bg Process List',
    category: 'shell',
    description: "List all background processes and their current status. Use this to: see what background processes are running (dev servers, watchers, builds), find a process ID you forgot, check if a background comm",
    tool: bgProcessList,
    safeByDefault: true,
  },
  {
    name: 'bg_process_output',
    exportName: 'bgProcessOutput',
    displayName: 'Bg Process Output',
    category: 'shell',
    description: "Read output from a background process started with dev_server or bash run_in_background=true. Use this to monitor dev servers, file watchers, build processes, or any background command. For processes ",
    tool: bgProcessOutput,
    safeByDefault: true,
  },
  {
    name: 'dev_server',
    exportName: 'devServer',
    displayName: 'Dev Server',
    category: 'shell',
    description: "Start a development server or long-running process with automatic log file capture.",
    tool: devServer,
    safeByDefault: false,
  },
  {
    name: 'web_fetch',
    exportName: 'webFetch',
    displayName: 'Web Fetch',
    category: 'web',
    description: "Fetch and extract content from a URL — works with web pages AND document files (PDF, DOCX, XLSX, PPTX, etc.). Document URLs are automatically detected and converted to markdown text.",
    tool: webFetch,
    safeByDefault: true,
  }
];

/** Get all built-in tools as ToolFunction array */
export function getAllBuiltInTools(): ToolFunction[] {
  return toolRegistry.map((entry) => entry.tool);
}

/** Get full tool registry with metadata */
export function getToolRegistry(): ToolRegistryEntry[] {
  return [...toolRegistry];
}

/** Get tools by category */
export function getToolsByCategory(category: ToolCategory): ToolRegistryEntry[] {
  return toolRegistry.filter((entry) => entry.category === category);
}

/** Get tool by name */
export function getToolByName(name: string): ToolRegistryEntry | undefined {
  return toolRegistry.find((entry) => entry.name === name);
}

/** Get tools that require connector configuration */
export function getToolsRequiringConnector(): ToolRegistryEntry[] {
  return toolRegistry.filter((entry) => entry.requiresConnector);
}

/** Get all unique category names */
export function getToolCategories(): ToolCategory[] {
  return [...new Set(toolRegistry.map((entry) => entry.category))];
}
