tool-groups.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Define tool group configuration
  2. export type ToolGroupConfig = {
  3. tools: readonly string[]
  4. alwaysAvailable?: boolean // Whether this group is always available and shouldn't show in prompts view
  5. }
  6. // Map of tool slugs to their display names
  7. export const TOOL_DISPLAY_NAMES = {
  8. execute_command: "run commands",
  9. read_file: "read files",
  10. write_to_file: "write files",
  11. apply_diff: "apply changes",
  12. search_files: "search files",
  13. list_files: "list files",
  14. list_code_definition_names: "list definitions",
  15. browser_action: "use a browser",
  16. use_mcp_tool: "use mcp tools",
  17. access_mcp_resource: "access mcp resources",
  18. ask_followup_question: "ask questions",
  19. attempt_completion: "complete tasks",
  20. switch_mode: "switch modes",
  21. new_task: "create new task",
  22. } as const
  23. // Define available tool groups
  24. export const TOOL_GROUPS: Record<string, ToolGroupConfig> = {
  25. read: {
  26. tools: ["read_file", "search_files", "list_files", "list_code_definition_names"],
  27. },
  28. edit: {
  29. tools: ["write_to_file", "apply_diff", "insert_content", "search_and_replace"],
  30. },
  31. browser: {
  32. tools: ["browser_action"],
  33. },
  34. command: {
  35. tools: ["execute_command"],
  36. },
  37. mcp: {
  38. tools: ["use_mcp_tool", "access_mcp_resource"],
  39. },
  40. modes: {
  41. tools: ["switch_mode", "new_task"],
  42. alwaysAvailable: true,
  43. },
  44. }
  45. export type ToolGroup = keyof typeof TOOL_GROUPS
  46. // Tools that are always available to all modes
  47. export const ALWAYS_AVAILABLE_TOOLS = [
  48. "ask_followup_question",
  49. "attempt_completion",
  50. "switch_mode",
  51. "new_task",
  52. ] as const
  53. // Tool name types for type safety
  54. export type ToolName = keyof typeof TOOL_DISPLAY_NAMES
  55. // Tool helper functions
  56. export function getToolName(toolConfig: string | readonly [ToolName, ...any[]]): ToolName {
  57. return typeof toolConfig === "string" ? (toolConfig as ToolName) : toolConfig[0]
  58. }
  59. export function getToolOptions(toolConfig: string | readonly [ToolName, ...any[]]): any {
  60. return typeof toolConfig === "string" ? undefined : toolConfig[1]
  61. }
  62. // Display names for groups in UI
  63. export const GROUP_DISPLAY_NAMES: Record<ToolGroup, string> = {
  64. read: "Read Files",
  65. edit: "Edit Files",
  66. browser: "Use Browser",
  67. command: "Run Commands",
  68. mcp: "Use MCP",
  69. }