Skip to content

Latest commit

 

History

History
413 lines (339 loc) · 15.2 KB

File metadata and controls

413 lines (339 loc) · 15.2 KB

Digital FTE - Development Checkpoint

Date: 2026-01-25 Status: Gold Tier 100% COMPLETE | Gmail + WhatsApp Automation! Last Session: WhatsApp Web automation with Playwright implemented


Migration Complete: OpenAI Agents SDK → Claude Code CLI

Why: Hackathon requirement states "All AI functionality should be implemented as Agent Skills" using Claude Code with a Claude Pro subscription.

What Changed:

  • Removed: openai-agents[litellm] dependency
  • Removed: Gemini API key requirement
  • Added: Claude Code CLI integration via subprocess
  • Updated: orchestrator.py to call claude --print command
  • Updated: config.py with Claude Code settings
  • Updated: .env files with new configuration

How It Works Now:

Watcher detects event → Creates task in /Needs_Action
                     ↓
Orchestrator reads task → Builds prompt with handbook + goals
                       ↓
Subprocess: claude --print --model sonnet --cwd vault_path
                       ↓
Claude Code (via Pro subscription) → Returns JSON action proposal
                       ↓
Auto-approve or → /Pending_Approval for human review

Quick Resume

"Continue Digital FTE from CHECKPOINT.md. Full system operational with:
- Claude Code CLI as reasoning engine (hackathon compliant!)
- Gmail read + reply FULLY WORKING (tested, emails sent!)
- WhatsApp Web automation with Playwright (NEW!)
- Next.js CEO Dashboard with real-time updates
- HITL approval workflow functional
Next: Test WhatsApp flow, demo video, social media API keys."

Current State

Tier Compliance: 100% Planned

Tier Status Key Deliverables
Bronze ✅ Complete Vault structure, filesystem watcher, 5 core skills
Silver ✅ Complete LinkedIn/WhatsApp skills, plan-creator, scheduling docs
Gold ✅ Complete Social media (FB/IG/Twitter), Odoo MCP, CEO briefing

What's Working (Tested) ✅

  • Orchestrator with Ralph Wiggum loop (5-min cycle)
  • Claude Code CLI (uses Claude Pro subscription - hackathon requirement!)
  • Filesystem watcher monitoring vault (fixed cascade issue)
  • Gmail FULL PIPELINE:
    • ✅ OAuth authentication
    • ✅ Smart filtering (ignores promotions/notifications)
    • ✅ Claude analyzes and proposes reply
    • ✅ Auto-approve high confidence actions
    • Actually sends email via Gmail API!
    • ✅ Thread replies (same conversation)
    • ✅ Marks original as read
  • HITL approval workflow (task → AI → proposal → /Pending_Approval)
  • Audit logging (JSONL + Markdown)
  • CLI commands: start, status, briefing, approve, reject, init, version
  • CEO Briefing generator (tested, generating reports)
  • Next.js Dashboard with:
    • Real-time status cards
    • Social Channels status (LinkedIn, WhatsApp, Twitter)
    • Task Queue with delete & auto-cleanup
    • Pending approvals with approve/reject + social icons
    • Activity feed from audit logs
    • 30-second auto-refresh polling
    • Toast notifications

What Needs Testing/Implementation

  • Social media API integrations (UI ready, need API keys)
  • Odoo connection (MCP ready, needs Odoo instance)
  • WhatsApp Playwright automation ✅ IMPLEMENTED!
  • End-to-end email reply flow ✅ DONE!
  • WhatsApp end-to-end test (scan QR, receive message, send reply)

Architecture Summary

                        ┌─────────────────┐
                        │  CEO Dashboard  │
                        │   (Next.js)     │
                        └────────┬────────┘
                                 │ API Routes
┌──────────┐    ┌──────────┐    ▼
│  Gmail   │───▶│ /Needs   │◀── Filesystem
│  Watcher │    │ _Action  │    Watcher
└──────────┘    └────┬─────┘
                     │
                     ▼
              ┌─────────────┐
              │ Ralph Loop  │
              │(Claude Code)│
              └──────┬──────┘
                     │
                     ▼
              ┌─────────────┐
              │  /Pending   │◀── Human Review
              │  _Approval  │    (Dashboard/CLI)
              └──────┬──────┘
                     │
            ┌────────┴────────┐
            ▼                 ▼
      ┌──────────┐     ┌──────────┐
      │ /Approved│     │/Rejected │
      │  → Done  │     └──────────┘
      └──────────┘

AI Stack: Claude Code CLI → Claude Pro Subscription (hackathon compliant!)


File Structure

Frontend - frontend/src/

app/
├── page.tsx                    # Dashboard home
├── layout.tsx                  # Root layout with Toaster
├── api/
│   ├── status/route.ts         # System health endpoint
│   ├── tasks/route.ts          # Task counts endpoint
│   ├── approvals/route.ts      # Pending approvals endpoint
│   ├── activity/route.ts       # Audit log feed endpoint
│   ├── approve/route.ts        # POST approve/reject
│   ├── metrics/route.ts        # Daily metrics endpoint
│   ├── social-channels/route.ts # Social media status (NEW)
│   ├── needs-action/route.ts   # Task queue CRUD (NEW)
│   └── cleanup/route.ts        # Auto-cleanup junk tasks (NEW)
components/dashboard/
├── top-nav.tsx                 # Header with refresh
├── status-cards.tsx            # System status cards
├── social-channels.tsx         # LinkedIn/WhatsApp/Twitter status (NEW)
├── task-queue.tsx              # Task queue with delete (NEW)
├── pending-approvals.tsx       # Approval queue with social icons
├── activity-feed.tsx           # Recent events list
└── metrics-chart.tsx           # Weekly activity chart
hooks/
└── use-dashboard.ts            # Polling hook (30s) + cleanup
lib/
├── types.ts                    # TypeScript interfaces + social types
├── vault.ts                    # Vault utilities + cleanup function
└── utils.ts                    # cn() helper

Agent Skills (13 total) - .claude/skills/

Bronze (5):  task-processor, email-handler, vault-manager, audit-logger, hitl-workflow
Silver (3):  linkedin-poster, whatsapp-handler, plan-creator
Gold (5):    facebook-manager, instagram-manager, twitter-manager, ceo-briefing, odoo-integration

Python Modules - backend/src/digital_fte/

Core:        models.py, config.py, logger.py, base_watcher.py, orchestrator.py, cli.py
Watchers:    gmail_watcher.py, filesystem_watcher.py, linkedin_watcher.py, social_media_watcher.py, whatsapp_watcher.py
MCP:         email_mcp.py, browser_mcp.py, odoo_mcp.py, whatsapp_mcp.py
New:         briefing_generator.py

Vault Structure - AI_Employee_Valut/

Inbox/, Needs_Action/, In_Progress/, Pending_Approval/, Approved/, Rejected/, Done/
Plans/, Briefings/, Accounting/, Logs/, People/, Metrics/
Dashboard.md, Company_Handbook.md, Business_Goals.md

Session 8 Additions (2026-01-25)

WhatsApp Automation - Implemented!

  1. watchers/whatsapp_watcher.py - Complete Playwright-based watcher

    • Persistent browser context (QR login saved in .whatsapp_session/)
    • Detects unread messages with priority keywords
    • Extracts contact name and message content
    • Sends messages via WhatsApp Web automation
  2. mcp/whatsapp_mcp.py - WhatsApp MCP for action execution

    • send_message() - Send to contact
    • reply_to_message() - Reply in context
    • execute_action() - Handle whatsapp_reply action type
  3. config.py - Added whatsapp_user_data_dir setting

  4. orchestrator.py - Registered WhatsApp watcher + MCP

    • Routes whatsapp_reply actions to WhatsAppMCP
  5. Updated exports in watchers/__init__.py and mcp/__init__.py

How WhatsApp Works

First run: Browser opens → Scan QR with phone → Session saved
         ↓
Watcher polls every 2 min → Detects unread messages
         ↓
Creates task in /Needs_Action with priority (P0-P3)
         ↓
Claude Code proposes reply → Requires human approval
         ↓
After approval → WhatsAppMCP sends message via Playwright

Key Selectors (WhatsApp Web 2026)

  • Chat list: #pane-side, [data-testid='cell-frame-container']
  • Unread badge: [data-testid='icon-unread-count']
  • Message input: [data-testid='conversation-compose-box-input']
  • Send button: [data-testid='send']

Session 7 Additions (2026-01-24)

Major Migration: OpenAI Agents SDK → Claude Code CLI

  • Removed openai-agents[litellm] dependency (49 packages removed!)
  • Removed Gemini API key requirement
  • Added subprocess calls to claude --print --model sonnet
  • Now uses Claude Pro subscription (hackathon compliant!)

Gmail Reply - FULLY WORKING!

  1. email_mcp.py - Complete rewrite to use GmailWatcher's send_email
  2. orchestrator.py - Wired up EmailMCP with Gmail watcher
  3. orchestrator.py - Added _extract_task_context() for email metadata
  4. base_watcher.py - Fixed JSON serialization for context

Tested Flow

Email arrives → Gmail watcher creates task
            → Claude Code analyzes (via CLI)
            → Proposes email_reply with body
            → Auto-approved (high confidence)
            → Email ACTUALLY SENT via Gmail API!
            → Task moved to /Done

Session 6 Additions (2026-01-23 Evening)

Created - Social Channels & Task Queue

  1. frontend/src/components/dashboard/social-channels.tsx - LinkedIn/WhatsApp/Twitter status
  2. frontend/src/components/dashboard/task-queue.tsx - Task queue with delete & auto-clean
  3. frontend/src/app/api/social-channels/route.ts - Social channels API
  4. frontend/src/app/api/needs-action/route.ts - Task queue CRUD API
  5. frontend/src/app/api/cleanup/route.ts - Auto-cleanup junk tasks API

Fixed - Critical Issues

  • AI Action Types - Fixed prompt to explicitly list valid action types (was causing email_operation error)
  • Gmail Filtering - Added smart filtering to ignore promotions/notifications (Pinterest, GitHub, etc.)
  • Filesystem Cascade - Fixed infinite task creation loop (now only monitors /Inbox)
  • Task Names - Improved parsing to show email subjects and meaningful titles

Enhanced

  • pending-approvals.tsx - Added LinkedIn, WhatsApp, Twitter icons
  • vault.ts - Added cleanupJunkTasks() function and better title parsing
  • types.ts - Added SocialChannelStatus, QueuedTask types
  • use-dashboard.ts - Added handleCleanupTasks, handleDeleteTask

Session 5 Additions (2026-01-23)

Created - Frontend Dashboard

  1. frontend/src/lib/types.ts - TypeScript interfaces
  2. frontend/src/lib/vault.ts - Vault file reading utilities
  3. frontend/src/hooks/use-dashboard.ts - Polling hook (30s)
  4. frontend/src/app/api/* - 6 API routes for dashboard
  5. frontend/src/components/dashboard/* - 5 dashboard components

Tested & Verified

  • ✅ CEO Briefing (digital-fte briefing) - Generates weekly reports
  • ✅ Gmail OAuth - Connected, detecting emails, creating tasks
  • ✅ Orchestrator (digital-fte start) - Full pipeline working
  • ✅ Dashboard UI - Real-time updates, approve/reject working

Fixed

  • frontend/src/components/ui/resizable.tsx - Import fix
  • frontend/src/components/ui/sonner.tsx - Light mode fix

Next Steps (Prioritized)

Completed ✅

  1. Test CEO Briefing - Working
  2. Gmail OAuth setup - Connected and processing emails
  3. Frontend Dashboard - Fully implemented

Before Submission

  1. Real-world testing (run for several days)
  2. Demo video showing full workflow
  3. Polish documentation

Optional (Platinum)

  1. Cloud VM deployment (Oracle Free Tier)
  2. Vault sync (Git-based)
  3. Odoo Community installation
  4. Social media API keys (LinkedIn, Twitter, etc.)

Key Commands

# Backend (run from backend/ folder)
cd backend
uv run digital-fte start           # Start orchestrator
uv run digital-fte status          # Show system status
uv run digital-fte briefing        # Generate CEO briefing
uv run digital-fte approve <task>  # Approve pending task
uv run digital-fte reject <task>   # Reject pending task

# Frontend (run from frontend/ folder)
cd frontend
bun dev                            # Start dashboard at localhost:3000
bun build                          # Production build

Environment Setup

# Required: Install and login to Claude Code CLI
npm install -g @anthropic-ai/claude-code
claude login  # Uses your Claude Pro subscription

# Required in backend/.env
CLAUDE_CODE_PATH=claude                # Path to Claude Code CLI
CLAUDE_CODE_MODEL=sonnet               # Claude model (sonnet, opus, haiku)
VAULT_PATH=../AI_Employee_Valut        # Relative path from backend/
GOOGLE_CREDENTIALS_PATH=credentials.json  # Gmail OAuth (download from GCP)

# Optional in frontend/.env.local
VAULT_PATH=../AI_Employee_Valut        # For API routes

Version History

Date Session Progress
2026-01-22 1 Architecture + core components
2026-01-22 2 Testing + Windows fixes (70%)
2026-01-23 3 AI integration with Gemini (85%)
2026-01-23 4 All tiers complete (100% planned)
2026-01-23 5 Frontend dashboard + Gmail OAuth (98%)
2026-01-23 6 Social channels UI + Task queue + Fixes (100%)
2026-01-24 7 Claude Code CLI migration + Gmail reply WORKING!
2026-01-25 8 WhatsApp automation with Playwright!

Key Files Reference

Purpose File
Main brain backend/src/digital_fte/orchestrator.py
Configuration backend/src/digital_fte/config.py
Project config backend/pyproject.toml
AI rules AI_Employee_Valut/Company_Handbook.md
Business context AI_Employee_Valut/Business_Goals.md
Skill index .claude/SKILL.md
Dashboard page frontend/src/app/page.tsx
Dashboard hook frontend/src/hooks/use-dashboard.ts
Vault utilities frontend/src/lib/vault.ts
This file CHECKPOINT.md

Testing Checklist

  • digital-fte start - Orchestrator runs
  • digital-fte briefing - CEO briefing generates
  • Gmail watcher - Detects emails, creates tasks
  • Gmail filtering - Ignores promotions/notifications
  • Gmail reply - Claude proposes, email SENT! ✅ NEW!
  • Filesystem watcher - Monitors vault changes (no cascade)
  • Dashboard loads at localhost:3000
  • Dashboard shows real vault data
  • Approve/Reject buttons work
  • Auto-refresh (30s polling) works
  • Social Channels card - Shows LinkedIn/WhatsApp/Twitter status
  • Task Queue - Shows tasks with snippets, delete works
  • Auto-cleanup - Removes junk tasks
  • Claude Code CLI integration ✅ NEW!
  • End-to-end email flow ✅ NEW!
  • Run for 24+ hours continuous
  • Demo video recorded
  • WhatsApp integration - Playwright watcher + MCP ✅ NEW!
  • WhatsApp end-to-end test (QR scan, message, reply)
  • Social media API keys configured