import { z } from 'zod';
import type { ToolDef } from '../tool-registry.js';

const UserRole = z.enum(['SUPER_ADMIN', 'INFLUENCE_ADMIN', 'MAP_ADMIN', 'USER', 'TEMP']);

export const peopleTools: ToolDef[] = [
  {
    name: 'people_search',
    description:
      'Search across all people in the CRM — aggregates users, campaign participants, ' +
      'shift signups, and canvass contacts into a unified view. ' +
      'Filter by name, email, phone, or tags.',
    inputSchema: {
      page: z.coerce.number().int().positive().default(1).describe('Page number'),
      limit: z.coerce.number().int().positive().max(100).default(20).describe('Items per page'),
      search: z.string().optional().describe('Search by name, email, or phone'),
      tag: z.string().optional().describe('Filter by tag'),
    },
    method: 'GET',
    path: '/api/people',
    tier: 1,
  },
  {
    name: 'users_list',
    description:
      'List registered platform users with their roles. ' +
      'Filter by role (SUPER_ADMIN, INFLUENCE_ADMIN, MAP_ADMIN, USER, TEMP) or search by name/email.',
    inputSchema: {
      page: z.coerce.number().int().positive().default(1).describe('Page number'),
      limit: z.coerce.number().int().positive().max(100).default(20).describe('Items per page'),
      search: z.string().optional().describe('Search by name or email'),
      role: UserRole.optional().describe('Filter by user role'),
    },
    method: 'GET',
    path: '/api/users',
    tier: 1,
  },
  {
    name: 'users_get',
    description:
      'Get detailed information about a specific user by ID, including role, ' +
      'registration date, and associated activity.',
    inputSchema: {
      id: z.string().describe('User ID'),
    },
    method: 'GET',
    path: '/api/users/:id',
    tier: 1,
  },
];
