tool.ts 993 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { z } from "zod"
  2. /**
  3. * ToolGroup
  4. */
  5. export const toolGroups = ["read", "edit", "browser", "command", "mcp", "modes"] as const
  6. export const toolGroupsSchema = z.enum(toolGroups)
  7. export type ToolGroup = z.infer<typeof toolGroupsSchema>
  8. /**
  9. * ToolName
  10. */
  11. export const toolNames = [
  12. "execute_command",
  13. "read_file",
  14. "write_to_file",
  15. "apply_diff",
  16. "insert_content",
  17. "search_and_replace",
  18. "search_files",
  19. "list_files",
  20. "list_code_definition_names",
  21. "browser_action",
  22. "use_mcp_tool",
  23. "access_mcp_resource",
  24. "ask_followup_question",
  25. "attempt_completion",
  26. "switch_mode",
  27. "new_task",
  28. "fetch_instructions",
  29. "codebase_search",
  30. "update_todo_list",
  31. ] as const
  32. export const toolNamesSchema = z.enum(toolNames)
  33. export type ToolName = z.infer<typeof toolNamesSchema>
  34. /**
  35. * ToolUsage
  36. */
  37. export const toolUsageSchema = z.record(
  38. toolNamesSchema,
  39. z.object({
  40. attempts: z.number(),
  41. failures: z.number(),
  42. }),
  43. )
  44. export type ToolUsage = z.infer<typeof toolUsageSchema>