#!/usr/bin/env python3
"""
Genesis Session 23: Supplemental Batch 3 — 20 agents to reach 200 total.
Focus: Additional high-value content (competitor comparisons, case studies, ad copy)
"""

import sys
sys.path.insert(0, '/mnt/e/genesis-system')

import time
import logging

logging.basicConfig(level=logging.INFO, format='%(asctime)s [%(levelname)s] %(message)s')
logger = logging.getLogger(__name__)

from core.multi_model_swarm import MultiModelSwarm

SYSTEM_PROMPT = """You are an expert Australian digital marketing copywriter specializing in AI voice agents and chatbots for SMBs.

PRODUCT: Sunaiva Talking Widget - AI Voice Agent for websites and phones.
PRICING: Essentials $197/mo, Business $397/mo, Growth $597/mo (~~$997/mo~~ anchor).
AGENCY COMMISSION: 20-33% recurring lifetime.
BRAND: Professional, ROI-focused, Australian English, no hype."""

TASKS = [
    # Competitor comparison pages (5)
    {
        'task': 'Write an SEO comparison page: "Sunaiva vs Smith.ai — Which AI Receptionist Is Better for Australian Businesses?" Cover features, pricing, language support, local numbers, integrations. 1,500 words. Position Sunaiva as the Australian-first option.',
        'agent_id': 'B3-001-vs-smithai', 'label': 'Comparison: Sunaiva vs Smith.ai'
    },
    {
        'task': 'Write an SEO comparison page: "Sunaiva vs Ruby Receptionist — AI vs Human Virtual Receptionists for Australian SMBs" Cover cost, availability, scalability, accuracy. 1,500 words.',
        'agent_id': 'B3-002-vs-ruby', 'label': 'Comparison: Sunaiva vs Ruby'
    },
    {
        'task': 'Write an SEO comparison page: "Sunaiva vs Dialpad AI — Best AI Phone System for Small Business Australia 2026" Cover voice quality, pricing, features. 1,500 words.',
        'agent_id': 'B3-003-vs-dialpad', 'label': 'Comparison: Sunaiva vs Dialpad'
    },
    {
        'task': 'Write an SEO comparison page: "Sunaiva vs Tidio — AI Chatbot vs AI Voice Agent: What Australian Businesses Really Need in 2026" Position voice as the next evolution beyond text chatbots. 1,500 words.',
        'agent_id': 'B3-004-vs-tidio', 'label': 'Comparison: Sunaiva vs Tidio'
    },
    {
        'task': 'Write an SEO comparison page: "Top 5 AI Receptionists for Australian Businesses in 2026 — Complete Comparison" Include Sunaiva, Smith.ai, Ruby, Dialpad, Tidio. Comparison matrix. Sunaiva ranked #1 with justification. 2,000 words.',
        'agent_id': 'B3-005-top5', 'label': 'Top 5 AI receptionists Australia'
    },
    # Case study templates (5)
    {
        'task': 'Write a detailed case study: "How a Sydney Dental Practice Reduced Missed Appointments by 73% with Sunaiva AI Receptionist" Include the problem, solution, implementation timeline, results with specific metrics, and ROI breakdown. 1,200 words. Use realistic but fictional practice details.',
        'agent_id': 'B3-006-case-dental', 'label': 'Case study: dental practice'
    },
    {
        'task': 'Write a detailed case study: "How a Brisbane Plumbing Company Captured $47K in After-Hours Jobs with AI Voice Agent" Include missed call analysis, Sunaiva implementation, 90-day results. 1,200 words.',
        'agent_id': 'B3-007-case-plumber', 'label': 'Case study: plumbing company'
    },
    {
        'task': 'Write a detailed case study: "How a Melbourne Digital Agency Added $8,500/mo in Recurring Revenue by Reselling AI Voice Widgets" Focus on the agency partner model, commission earnings, client retention improvement. 1,200 words.',
        'agent_id': 'B3-008-case-agency', 'label': 'Case study: digital agency partner'
    },
    {
        'task': 'Write a detailed case study: "How a Gold Coast Real Estate Agency Never Misses a Property Enquiry with Sunaiva" Include lead capture rates, response time improvement, vendor satisfaction. 1,200 words.',
        'agent_id': 'B3-009-case-realestate', 'label': 'Case study: real estate agency'
    },
    {
        'task': 'Write a detailed case study: "How a Perth Law Firm Saved $4,200/mo by Replacing Their Receptionist with AI" Include cost analysis, client satisfaction scores, intake automation results. 1,200 words.',
        'agent_id': 'B3-010-case-legal', 'label': 'Case study: law firm'
    },
    # Google Ads copy (5)
    {
        'task': 'Write 10 Google Ads for "AI receptionist Australia" keyword. For each ad provide: 3 headlines (30 chars each), 2 descriptions (90 chars each), display URL path, and 4 sitelink extensions. Target Australian business owners. Include responsive search ad variants.',
        'agent_id': 'B3-011-ads-receptionist', 'label': 'Google Ads: AI receptionist'
    },
    {
        'task': 'Write 10 Google Ads for "chatbot for business website" keyword targeting Australian SMBs. 3 headlines + 2 descriptions each. Include callout extensions and structured snippets.',
        'agent_id': 'B3-012-ads-chatbot', 'label': 'Google Ads: business chatbot'
    },
    {
        'task': 'Write 10 Google Ads for trade-specific keywords: "plumber answering service", "electrician after hours", "tradie call answering". 3 headlines + 2 descriptions each. Australian voice.',
        'agent_id': 'B3-013-ads-trades', 'label': 'Google Ads: tradies'
    },
    {
        'task': 'Write 10 Facebook/Meta ad variants for Sunaiva Talking Widget targeting Australian agency owners. Include: primary text (125 chars), headline (40 chars), description (30 chars), CTA button recommendation. Cover angles: revenue growth, client retention, passive income, competitive advantage.',
        'agent_id': 'B3-014-ads-facebook', 'label': 'Facebook Ads: agency partners'
    },
    {
        'task': 'Write 10 LinkedIn ad variants targeting Australian digital agency owners and marketing consultants. Include: intro text (150 words), headline, CTA. Angles: recurring revenue, AI differentiation, white-label opportunity, client results.',
        'agent_id': 'B3-015-ads-linkedin', 'label': 'LinkedIn Ads: agency partners'
    },
    # Social media content (5)
    {
        'task': 'Write 20 LinkedIn posts for a "build in public" content series about launching an AI voice product in Australia. Mix of: founder stories, product updates, industry insights, customer wins, behind-the-scenes. Each 100-200 words. Include 3 hashtags per post.',
        'agent_id': 'B3-016-linkedin-series', 'label': 'LinkedIn build-in-public series'
    },
    {
        'task': 'Write 15 tweet/X threads (5-7 tweets each) about AI voice agents for business. Topics: ROI of AI receptionists, missed call revenue loss, comparing AI vs human receptionists, voice AI trends 2026, Australian SMB automation. Engaging, data-driven.',
        'agent_id': 'B3-017-twitter-threads', 'label': 'Twitter/X threads'
    },
    {
        'task': 'Write 10 Reddit posts for r/smallbusiness, r/entrepreneur, r/australia, r/AusFinance. Topics: AI receptionists saving money, tradies using AI, automation ROI. Write as a genuine user sharing experience, NOT as a brand. Subtle, valuable, community-appropriate.',
        'agent_id': 'B3-018-reddit-posts', 'label': 'Reddit organic posts'
    },
    {
        'task': 'Write 10 YouTube video scripts (3-5 min each) for a channel about AI for Australian businesses. Topics: "I Replaced My Receptionist with AI", "How AI Chatbots Make Money While You Sleep", "The $197/mo Tool That Replaced a $5K/mo Employee". Include intro hook, main content, CTA.',
        'agent_id': 'B3-019-youtube-scripts', 'label': 'YouTube video scripts'
    },
    {
        'task': 'Write a complete email nurture sequence (7 emails over 21 days) for Sunaiva waitlist signups. Goal: convert waitlist to paid customer. Emails: welcome + product overview, founder story, use case showcase, social proof, pricing deep-dive, limited-time beta offer, final urgency. Each 200-300 words.',
        'agent_id': 'B3-020-nurture-sequence', 'label': 'Waitlist nurture email sequence'
    },
]

def main():
    print("=" * 80)
    print("BATCH 3 SUPPLEMENT: 20 More Agents (reaching 200 total)")
    print("=" * 80)

    swarm = MultiModelSwarm()

    for t in TASKS:
        t['model'] = 'openrouter-minimax'
        t['system_prompt'] = SYSTEM_PROMPT

    print(f"Firing {len(TASKS)} agents...")
    start = time.time()

    results = swarm.parallel_execute(
        tasks=TASKS,
        default_model='openrouter-minimax',
        max_workers=20
    )

    elapsed = time.time() - start
    summary_path = swarm.save_results(
        results,
        '/mnt/e/genesis-system/swarm-output/session23/batch3-supplement'
    )

    success = sum(1 for r in results if r['status'] == 'success')
    print(f"\nBatch 3 Complete: {success}/{len(results)} succeeded in {elapsed:.1f}s")
    print(f"Summary: {summary_path}")
    print()
    print(f"GRAND TOTAL: 100 (B1) + 80 (B2) + {len(results)} (B3) = {100+80+len(results)} agents")
    print(f"GRAND SUCCESS: 100 + 79 + {success} = {100+79+success}")


if __name__ == "__main__":
    main()
