export function renderSummary(config: Record<string, any>): string {
  const lines: string[] = [];

  const models = config.models ?? {};
  const tiers = ['default', 'fast', 'complex', 'local']
    .filter(t => models[t])
    .map(t => `${t}:${models[t].provider}`)
    .join(', ');
  lines.push(`  Models:     ${tiers || 'none configured'}`);

  const channels: string[] = [];
  if (config.server?.port) {channels.push('webchat');}
  if (config.telegram) {channels.push('telegram');}
  if (config.discord) {channels.push('discord');}
  if (config.slack) {channels.push('slack');}
  if (config.whatsapp) {channels.push('whatsapp');}
  lines.push(`  Channels:   ${channels.join(', ') || 'none'}`);

  const embedding = config.memory?.embedding;
  const memoryStatus = embedding?.enabled ? `vector search (${embedding.provider})` : 'keyword search (no embeddings)';
  lines.push(`  Memory:     ${memoryStatus}`);

  const auto = config.automation ?? {};
  const autoFeatures: string[] = [];
  if (auto.cron?.length > 0) {autoFeatures.push(`${auto.cron.length} cron jobs`);}
  if (auto.webhooks?.length > 0) {autoFeatures.push('webhooks');}
  if (auto.gmail?.enabled) {autoFeatures.push('gmail');}
  if (auto.gcal?.enabled) {autoFeatures.push('gcal');}
  if (auto.gdocs?.enabled) {autoFeatures.push('gdocs');}
  if (auto.gdrive?.enabled) {autoFeatures.push('gdrive');}
  if (auto.gtasks?.enabled) {autoFeatures.push('gtasks');}
  if (auto.heartbeat?.enabled) {autoFeatures.push('heartbeat');}
  lines.push(`  Automation: ${autoFeatures.join(', ') || 'none'}`);

  const secFeatures: string[] = [];
  secFeatures.push(`tools:${config.tools?.profile ?? 'full'}`);
  if (config.sandbox?.enabled) {secFeatures.push('sandbox');}
  if (config.pairing?.enabled) {secFeatures.push('pairing');}
  lines.push(`  Security:   ${secFeatures.join(', ')}`);

  const gw: string[] = [];
  gw.push(`port ${config.server?.port ?? 18800}`);
  if (config.server?.token) {gw.push('auth');}
  if (config.server?.lock) {gw.push('locked');}
  if (config.server?.tailscale?.serve) {gw.push('tailscale');}
  lines.push(`  Gateway:    ${gw.join(', ')}`);

  return lines.join('\n');
}
