export interface Project {
  id: string;
  name: string;
  path: string;
  cloned_from: string | null;
  base_branch: string;
  created_at: string;
}

export interface TuleapCredentialsSafe {
  id: string;
  tuleap_url: string;
  username: string;
}

export type AgentRole = "analyst" | "developer";
export type AgentTool = "codex" | "claude_code";

export interface Agent {
  id: string;
  name: string;
  role: AgentRole;
  tool: AgentTool;
  custom_prompt: string;
  is_default: boolean;
  created_at: string;
  updated_at: string;
}

export interface Filter {
  field: string;
  operator: string;
  value: string[];
}

export interface FilterGroup {
  conditions: Filter[];
}

export interface TrackerField {
  field_id: number;
  label: string;
  field_type: string;
  values: FieldValue[];
}

export interface FieldValue {
  id: number;
  label: string;
}

export interface WatchedTracker {
  id: string;
  project_id: string;
  tracker_id: number;
  tracker_label: string;
  polling_interval: number;
  analyst_agent_id: string | null;
  developer_agent_id: string | null;
  filters: FilterGroup[];
  enabled: boolean;
  status: string;
  last_polled_at: string | null;
  created_at: string;
}

export interface ProcessedTicket {
  id: string;
  tracker_id: string;
  artifact_id: number;
  artifact_title: string;
  artifact_data: string;
  status: string;
  analyst_report: string | null;
  developer_report: string | null;
  worktree_path: string | null;
  branch_name: string | null;
  detected_at: string;
  processed_at: string | null;
}

export interface Worktree {
  id: string;
  ticket_id: string;
  path: string;
  branch_name: string;
  status: string;
  created_at: string;
  merged_at: string | null;
  merged_into: string | null;
}

export interface TicketResult {
  ticket: ProcessedTicket;
  worktree: Worktree | null;
}

export interface OrchaiNotification {
  id: string;
  project_id: string;
  ticket_id: string | null;
  notification_type: string;
  title: string;
  message: string;
  read: boolean;
  created_at: string;
}
