export type WizardMode = 'quick' | 'advanced';
export type InstallAction = 'fresh' | 'keep' | 'reconfigure' | 'reset';
export type CommunicationStyle = 'direct' | 'friendly' | 'formal';
export type RuntimeName = 'claude' | 'codex' | 'opencode' | 'pi';

export type MenuSection =
  | 'quick-start'
  | 'providers'
  | 'identity'
  | 'skills'
  | 'gateway'
  | 'advanced'
  | 'finish';

export type AgentIntent = 'general' | 'software-dev' | 'devops' | 'research' | 'content' | 'custom';

export type ProviderType = 'anthropic' | 'openai' | 'none';

export interface SoulConfig {
  agentName?: string;
  roleDescription?: string;
  communicationStyle?: CommunicationStyle;
  accessibility?: string;
  customGuardrails?: string;
}

export interface UserConfig {
  userName?: string;
  pronouns?: string;
  timezone?: string;
  background?: string;
  accessibilitySection?: string;
  communicationPrefs?: string;
  personalBoundaries?: string;
  projectsTable?: string;
}

export interface GitProvider {
  name: string;
  url: string;
  cli: string;
  purpose: string;
}

export interface ToolsConfig {
  gitProviders?: GitProvider[];
  credentialsLocation?: string;
  customToolsSection?: string;
}

export interface RuntimeState {
  detected: RuntimeName[];
  mcpConfigured: boolean;
}

export interface HooksState {
  accepted: boolean;
  acceptedAt?: string;
}

export type GatewayStorageTier = 'local' | 'standalone' | 'federated';

export interface GatewayAdminState {
  name: string;
  email: string;
  /** Plaintext password held in memory only for the duration of the wizard run. */
  password: string;
}

export interface GatewayState {
  host: string;
  port: number;
  tier: GatewayStorageTier;
  databaseUrl?: string;
  valkeyUrl?: string;
  anthropicKey?: string;
  corsOrigin: string;
  /**
   * Raw hostname the user entered (e.g. "localhost", "myserver.example.com").
   * The full CORS origin (`corsOrigin`) is derived from this + protocol + webUiPort.
   */
  hostname?: string;
  /** True when .env + mosaic.config.json were (re)generated in this run. */
  regeneratedConfig?: boolean;
  admin?: GatewayAdminState;
  /** Populated after bootstrap/setup succeeds. */
  adminTokenIssued?: boolean;
}

export interface WizardState {
  mosaicHome: string;
  sourceDir: string;
  mode: WizardMode;
  installAction: InstallAction;
  soul: SoulConfig;
  user: UserConfig;
  tools: ToolsConfig;
  runtimes: RuntimeState;
  selectedSkills: string[];
  hooks?: HooksState;
  gateway?: GatewayState;
  /** Tracks which menu sections have been completed in drill-down mode. */
  completedSections?: Set<MenuSection>;
  /** The user's chosen agent intent category. */
  agentIntent?: AgentIntent;
  /** The LLM provider API key entered during setup. */
  providerKey?: string;
  /** Detected provider type based on API key prefix. */
  providerType?: ProviderType;
}
