Now add the `initPlaybookDropdown()` function and call it. Let me find a good spot — right after the playbooks constant.


1567:        let selectedAgent = 'general';


  1680→                        name: 'Optimal Quote Recommendation',
  1681→                        agent: 'quote_analyst',
  1682→                        prompt: 'Based on all previous analysis, recommend the optimal quote:\n\n1. RECOMMENDED PRICE: Exact amount with justification\n2. FLOOR PRICE: Minimum acceptable amount\n3. CEILING PRICE: Maximum we could reasonably charge\n4. PRESENTATION FORMAT: How to structure the quote document for maximum impact\n5. WHAT TO INCLUDE: Line items, value descriptions, terms that favor us\n6. WHAT TO EXCLUDE: Items to hold back for negotiation leverage\n7. TIMING: When to send the quote for best acceptance probability\n8. FOLLOW-UP SCRIPT: What to say 3 days after sending if no response\n9. MULTI-ROUND PLAN: If they push back, what\'s the next version of the quote?'
  1683→                    }
  1684→                ]
  1685→            },
  1686→
  1687→            // ---- FULL RELATIONSHIP ANALYSIS ----
  1688→            'relationship': {
  1689→                name: 'Full Relationship Analysis',
  1690→                description: 'Comprehensive relationship health check',
  1691→                passes: [
  1692→                    {
  1693→                        id: 'timeline',
  1694→                        name: 'Business Relationship Timeline',
  1695→                        agent: 'general',
  1696→                        prompt: 'Analyze the COMPLETE email history chronologically. Build a detailed timeline of the business relationship:\n\n1. KEY MILESTONES: When did the relationship start? What were the major projects/deals? When did things start going wrong? When did we lose them?\n2. TURNING POINTS: Identify the exact moments where the relationship shifted negatively. Quote specific emails.\n3. OUR MISTAKES: What did we do wrong? Late deliveries, missed expectations, poor communication, pricing issues? Be brutally honest.\n4. THEIR SATISFACTION CURVE: Rate their satisfaction (1-10) at each major point in the timeline.\n5. UNRESOLVED ISSUES: What was never properly addressed or closed?\n6. LAST INTERACTION: What was the tone and content of our last exchange? Did we leave the door open?'
  1697→                    },
  1698→                    {
  1699→                        id: 'profiles',

                        name: 'Optimal Quote Recommendation',
                        agent: 'quote_analyst',
                        prompt: 'Based on all previous analysis, recommend the optimal quote:\n\n1. RECOMMENDED PRICE: Exact amount with justification\n2. FLOOR PRICE: Minimum acceptable amount\n3. CEILING PRICE: Maximum we could reasonably charge\n4. PRESENTATION FORMAT: How to structure the quote document for maximum impact\n5. WHAT TO INCLUDE: Line items, value descriptions, terms that favor us\n6. WHAT TO EXCLUDE: Items to hold back for negotiation leverage\n7. TIMING: When to send the quote for best acceptance probability\n8. FOLLOW-UP SCRIPT: What to say 3 days after sending if no response\n9. MULTI-ROUND PLAN: If they push back, what\'s the next version of the quote?'
                    }
                ]
            },

            // ---- FULL RELATIONSHIP ANALYSIS ----
            'relationship': {
                name: 'Full Relationship Analysis',
                description: 'Comprehensive relationship health check',
                passes: [
                    {
                        id: 'timeline',
                        name: 'Business Relationship Timeline',
                        agent: 'general',
                        prompt: 'Analyze the COMPLETE email history chronologically. Build a detailed timeline of the business relationship:\n\n1. KEY MILESTONES: When did the relationship start? What were the major projects/deals? When did things start going wrong? When did we lose them?\n2. TURNING POINTS: Identify the exact moments where the relationship shifted negatively. Quote specific emails.\n3. OUR MISTAKES: What did we do wrong? Late deliveries, missed expectations, poor communication, pricing issues? Be brutally honest.\n4. THEIR SATISFACTION CURVE: Rate their satisfaction (1-10) at each major point in the timeline.\n5. UNRESOLVED ISSUES: What was never properly addressed or closed?\n6. LAST INTERACTION: What was the tone and content of our last exchange? Did we leave the door open?'
                    },
                    {
                        id: 'profiles',


  1720→        // ============================================
  1721→        // TOKEN ESTIMATION
  1722→        // ============================================
  1723→        const MODEL_LIMITS = {
  1724→            'claude-opus-4-6': 200000,
  1725→            'claude-sonnet-4-6': 200000,
  1726→            'claude-sonnet-4-5-20250929': 200000,
  1727→            'claude-3-5-sonnet-20241022': 200000,
  1728→            'claude-opus-4-5-20250929': 200000,
  1729→            'claude-3-opus-20240229': 200000,
  1730→            'claude-3-5-haiku-20241022': 200000,
  1731→            'gpt-4o': 128000,
  1732→            'gpt-4o-mini': 128000,
  1733→            'gpt-4-turbo': 128000,
  1734→            'gpt-4.1': 1000000,
  1735→            'gpt-4.1-mini': 1000000,
  1736→            'o3': 200000,
  1737→            'o3-mini': 200000,
  1738→            'o4-mini': 200000,
  1739→            'gemini-2.0-flash': 1048576,
  1740→            'gemini-2.5-pro-preview-05-06': 1048576,
  1741→            'gemini-2.5-flash-preview-04-17': 1048576,
  1742→            'grok-3': 131072,
  1743→            'grok-3-mini': 131072,
  1744→            'deepseek-chat': 64000,

        // ============================================
        // TOKEN ESTIMATION
        // ============================================
        const MODEL_LIMITS = {
            'claude-opus-4-6': 200000,
            'claude-sonnet-4-6': 200000,
            'claude-sonnet-4-5-20250929': 200000,
            'claude-3-5-sonnet-20241022': 200000,
            'claude-opus-4-5-20250929': 200000,
            'claude-3-opus-20240229': 200000,
            'claude-3-5-haiku-20241022': 200000,
            'gpt-4o': 128000,
            'gpt-4o-mini': 128000,
            'gpt-4-turbo': 128000,
            'gpt-4.1': 1000000,
            'gpt-4.1-mini': 1000000,
            'o3': 200000,
            'o3-mini': 200000,
            'o4-mini': 200000,
            'gemini-2.0-flash': 1048576,
            'gemini-2.5-pro-preview-05-06': 1048576,
            'gemini-2.5-flash-preview-04-17': 1048576,
            'grok-3': 131072,
            'grok-3-mini': 131072,
            'deepseek-chat': 64000,


Good. I'll add `initPlaybookDropdown()` right before the TOKEN ESTIMATION section, and I need to find where it gets called on page load. Let me search for DOMContentLoaded or window.onload or a page init section.


2912:        document.addEventListener('DOMContentLoaded', function() {


2912→        document.addEventListener('DOMContentLoaded', function() {
  2913→            loadProviders();
  2914→            loadConversationHistory();
  2915→            initAgentButtons();
  2916→            updateTokenEstimate();
  2917→            // Load contact memories if we have a primary contact
  2918→            if (primaryContactId) {
  2919→                loadContactMemories(primaryContactId);
  2920→            }
  2921→        });
  2922→
  2923→        // Load AI providers from API
  2924→        async function loadProviders() {
  2925→            try {
  2926→                const response = await fetch('../aiapi/api_opus/api/query.php?action=providers');
  2927→                const data = await response.json();
  2928→
  2929→                if (data.success) {
  2930→                    providers = data.providers;
  2931→                    renderProviders();
  2932→                }
  2933→            } catch (error) {
  2934→                console.error('Failed to load providers:', error);
  2935→                document.getElementById('provider-grid').innerHTML =
  2936→                    '
Failed to load AI providers
';
  2937→            }
  2938→        }
  2939→
  2940→        // Render provider selection (multi-select with checkboxes)
  2941→        function renderProviders() {

document.addEventListener('DOMContentLoaded', function() {
            loadProviders();
            loadConversationHistory();
            initAgentButtons();
            updateTokenEstimate();
            // Load contact memories if we have a primary contact
            if (primaryContactId) {
                loadContactMemories(primaryContactId);
            }
        });

        // Load AI providers from API
        async function loadProviders() {
            try {
                const response = await fetch('../aiapi/api_opus/api/query.php?action=providers');
                const data = await response.json();

                if (data.success) {
                    providers = data.providers;
                    renderProviders();
                }
            } catch (error) {
                console.error('Failed to load providers:', error);
                document.getElementById('provider-grid').innerHTML =
                    '
Failed to load AI providers
';
            }
        }

        // Render provider selection (multi-select with checkboxes)
        function renderProviders() {


Now I'll add `initPlaybookDropdown()` and add it to the DOMContentLoaded handler.


Edit

        // ============================================
        // PLAYBOOK DROPDOWN INIT
        // ============================================
        function initPlaybookDropdown() {
            var sel = document.getElementById('deep-analysis-playbook');
            if (!sel) return;
            for (var key in DEEP_ANALYSIS_PLAYBOOKS) {
                var pb = DEEP_ANALYSIS_PLAYBOOKS[key];
                var opt = document.createElement('option');
                opt.value = key;
                opt.textContent = pb.name + ' (' + pb.passes.length + ' passes)';
                opt.title = pb.description;
                sel.appendChild(opt);
            }
        }

        // ============================================
        // TOKEN ESTIMATION
        // ============================================