run-agent-session.sh
1 #!/bin/sh 2 # run-agent-session.sh — Launch a Tier C interactive Claude Code session for a named agent. 3 # 4 # Usage: 5 # ./scripts/run-agent-session.sh <agent> 6 # 7 # Available agents: 8 # security_audit — Security Engineer (Opus, max, thinking on) 9 # compliance_audit — Compliance Auditor (Opus, high, thinking on) 10 # seo_specialist — SEO Specialist (Sonnet, medium) 11 # automation_audit — Automation Governance Architect (Sonnet, medium) 12 # software_architect — Software Architect (Opus, max, thinking on) 13 # brand_guardian — Brand Guardian (Sonnet, medium) 14 # colorcraft_report — Consolidated colorcraft-ai.com report (Sonnet, medium) 15 # 16 # Tier C agents need interactive tool access (WebFetch, Read, Grep, etc.) and 17 # cannot run in orchestrator pipe mode (claude -p is stateless text-in/text-out). 18 # 19 # This script marks the agent as run in logs/orchestrator-gates.json so the 20 # due-notification system knows it's been executed. 21 22 set -e 23 SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 24 PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" 25 cd "$PROJECT_ROOT" 26 27 GATE_FILE="logs/orchestrator-gates.json" 28 29 # Load claude binary (same logic as orchestrator) 30 CLAUDE_BIN="" 31 if [ -d "$HOME/.local/share/claude/versions" ]; then 32 for _v in $(ls -1 "$HOME/.local/share/claude/versions" 2>/dev/null | sort -V -r); do 33 _candidate="$HOME/.local/share/claude/versions/$_v" 34 if [ -x "$_candidate" ] && [ -s "$_candidate" ]; then 35 CLAUDE_BIN="$_candidate" 36 break 37 fi 38 done 39 fi 40 [ -z "$CLAUDE_BIN" ] && CLAUDE_BIN=$(command -v claude 2>/dev/null || echo "claude") 41 42 mark_ran() { 43 _key="$1" 44 node -e " 45 const fs = require('fs'); 46 let d = {}; try { d = JSON.parse(fs.readFileSync('$GATE_FILE','utf8')); } catch {} 47 d['$_key'] = new Date().toISOString(); 48 fs.writeFileSync('$GATE_FILE', JSON.stringify(d, null, 2)); 49 " 2>/dev/null || true 50 } 51 52 AGENT="$1" 53 54 case "$AGENT" in 55 security_audit) 56 echo "Launching Security Engineer (Opus, max, thinking on)..." 57 echo "This will perform a deep security audit of 333Method and 2Step." 58 echo "" 59 PROMPT='Run a Security Engineer audit on 333Method and 2Step. Review: (1) API key handling in load-env.js and .env files, (2) Twilio webhook authentication in src/inbound/sms.js, (3) PayPal integration in src/payment/paypal.js, (4) unsigned unsubscribe tokens in 2Step src/outreach/email.js, (5) stealth-browser SSRF risk, (6) SQL injection review of all DB queries. Output findings as JSON with severity/file/line/description.' 60 MODEL="claude-opus-4-6" 61 EFFORT="max" 62 GATE_KEY="tier_c_security_audit" 63 ;; 64 compliance_audit) 65 echo "Launching Compliance Auditor (Opus, high, thinking on)..." 66 PROMPT='Run a Compliance Auditor review on 333Method outreach system. Check: (1) CAN-SPAM compliance in email templates, (2) TCPA compliance in SMS sending (business hours, opt-out), (3) GDPR country blocking logic in src/config/countries.js, (4) unsubscribe honoring in src/outreach/, (5) 72-hour cooldown enforcement. Also audit 2Step CAN-SPAM compliance in src/outreach/email.js.' 67 MODEL="claude-opus-4-6" 68 EFFORT="high" 69 GATE_KEY="tier_c_compliance_audit" 70 ;; 71 seo_specialist) 72 echo "Launching SEO Specialist (Sonnet, medium)..." 73 PROMPT='Run an SEO Specialist audit on colorcraft-ai.com. Fetch the site, analyze technical SEO (meta tags, page speed indicators, structured data, sitemap, robots.txt), keyword opportunities, content gaps, and link building potential. Output a prioritized report of changes for Base44 to implement.' 74 MODEL="claude-sonnet-4-6" 75 EFFORT="medium" 76 GATE_KEY="tier_c_seo_audit" 77 ;; 78 automation_audit) 79 echo "Launching Automation Governance Architect (Sonnet, medium)..." 80 PROMPT='Run an Automation Governance audit. Read the cron_jobs table (sqlite3 db/sites.db "SELECT * FROM cron_jobs"), review all cron jobs in src/cron/ and the orchestrator in scripts/claude-orchestrator.sh. Identify: redundant jobs, poor sequencing, missing error handling, jobs that should be consolidated. Output a ranked list of changes.' 81 MODEL="claude-sonnet-4-6" 82 EFFORT="medium" 83 GATE_KEY="tier_c_automation_audit" 84 ;; 85 software_architect) 86 echo "Launching Software Architect (Opus, max, thinking on)..." 87 PROMPT='Run a Software Architect review. Evaluate: (1) 333Method 9-stage pipeline architecture — are stages well-separated? coupling issues? (2) @mmo/* package extraction readiness — what can be safely extracted now? (3) distributed-agent-system plan in docs/plans/distributed-agent-system.md — are there simpler alternatives to the hybrid MCP+Redis approach? Output an architecture decision record (ADR) with recommendations.' 88 MODEL="claude-opus-4-6" 89 EFFORT="max" 90 GATE_KEY="tier_c_software_architect" 91 ;; 92 brand_guardian) 93 echo "Launching Brand Guardian (Sonnet, medium)..." 94 PROMPT='Run a Brand Guardian review across auditandfix.com, 2Step, and colorcraft-ai.com. Fetch each site and evaluate: visual consistency, messaging tone, value proposition clarity, call-to-action alignment. Output a brand consistency scorecard with specific recommendations per property.' 95 MODEL="claude-sonnet-4-6" 96 EFFORT="medium" 97 GATE_KEY="tier_c_brand_guardian" 98 ;; 99 colorcraft_report) 100 echo "Launching colorcraft-ai.com consolidated report (Sonnet, medium)..." 101 PROMPT='Generate a consolidated improvement report for colorcraft-ai.com (hosted on Base44). Run these analyses and combine into a single actionable report: (1) SEO audit — meta tags, keywords, structured data, (2) UX review — navigation, CTA placement, mobile experience, (3) Legal compliance — privacy policy, terms, cookie consent, accessibility, (4) Ad creative recommendations — headline/copy suggestions for Google/Meta ads, (5) Tracking setup — what analytics and conversion tracking should be added. Format the report as step-by-step changes that a Base44 LLM can implement.' 102 MODEL="claude-sonnet-4-6" 103 EFFORT="medium" 104 GATE_KEY="tier_c_colorcraft_report" 105 ;; 106 *) 107 echo "Usage: $0 <agent>" 108 echo "" 109 echo "Available agents:" 110 echo " security_audit — Security Engineer (Opus, max)" 111 echo " compliance_audit — Compliance Auditor (Opus, high)" 112 echo " seo_specialist — SEO Specialist (Sonnet, medium)" 113 echo " automation_audit — Automation Governance (Sonnet, medium)" 114 echo " software_architect — Software Architect (Opus, max)" 115 echo " brand_guardian — Brand Guardian (Sonnet, medium)" 116 echo " colorcraft_report — colorcraft-ai.com report (Sonnet, medium)" 117 echo "" 118 echo "Check logs/agents-due.json to see which agents are currently overdue." 119 exit 1 120 ;; 121 esac 122 123 echo "Model: $MODEL | Effort: $EFFORT" 124 echo "Prompt: $(echo "$PROMPT" | head -c 120)..." 125 echo "" 126 127 "$CLAUDE_BIN" --model "$MODEL" --effort "$EFFORT" \ 128 --allowedTools "WebFetch,WebSearch,Read,Grep,Glob,Bash" \ 129 -p "$PROMPT" 2>&1 130 131 mark_ran "$GATE_KEY" 132 echo "" 133 echo "Session complete. Gate updated: $GATE_KEY"