AI Workforce V1 — Completion Report
Social Media Casa · August 15, 2026 · Confidential — Admin Only
Project Objective
Prepare SocialMediaCasa.com to support an external AI workforce that will eventually operate a substantial portion of daily company activity. Airo serves as the primary application, system of record, database layer, authentication layer, admin control layer, and secure API gateway for all AI agents. The external AI workforce will be built using Relevance AI or a compatible agent platform. The architecture is vendor-agnostic — any authorized external AI system can interact through the secure API layer.
✅ Completed
Database Architecture
| Table / Change | Type | Notes |
|---|---|---|
| ai_agent | New table | 4 agents seeded: Chief of Staff, Brand Acquisition Manager, Brand SDR, Creator Success Manager |
| agent_action_log | New table | Immutable audit log — every meaningful AI action recorded |
| agent_approval | New table | Pending / approved / rejected / expired approval requests |
| agent_escalation | New table | Severity-ranked escalations: informational → critical |
| agent_performance | New table | Per-agent reporting period stats + attributed revenue |
| agent_settings | New table | Per-agent autonomy config, rate limits, approval requirements |
| ai_system_control | New table | Global emergency pause with audit trail |
| brand_lead | New table | AI-discovered brand prospects with full pipeline + lead scoring |
| internal_events | New table | Pollable event log for external AI consumers |
| creator_profile | Extended | Added: activationScore, activationStatus, creatorStatus, verificationStatus, lastActiveAt, phone, tiktokUrl, instagramUrl, youtubeUrl, otherSocialUrl |
| brand_profile | Extended | Added: brandStatus, totalCampaigns, activeCampaigns, completedCampaigns, totalSpend, lastActiveAt, companySize, companyDescription, socialUrls |
Creator Activation Score
Auto-calculates on profile save and application submission. Maximum score: 100.
| Event | Points |
|---|---|
| Account created | 10 |
| Profile image uploaded | 5 |
| Bio completed | 10 |
| Niche selected | 10 |
| At least one social account connected | 15 |
| Portfolio / examples uploaded | 20 |
| Opportunity viewed | 5 |
| First application submitted | 15 |
| First campaign completed | 10 |
Status tiers: ACTIVE (80–100) · NEARLY ACTIVE (50–79) · NEEDS HELP (20–49) · AT RISK (0–19)
Secure Agent API — /api/agents/*
All endpoints require Authorization: Bearer <agent-key>. Rate limited to 100 requests / 15 min per key. Emergency pause enforced at middleware level.
| Method | Endpoint | Purpose | Autonomy |
|---|---|---|---|
| GET | /api/agents/creator/:id | Fetch creator profile + activation score | GREEN |
| GET | /api/agents/creators/incomplete | List creators with activation score < 80 | GREEN |
| GET | /api/agents/creators/inactive | List creators inactive > 30 days | GREEN |
| GET | /api/agents/brand/:id | Fetch brand profile + campaign stats | GREEN |
| GET | /api/agents/brand-leads | List brand leads with filters + pagination | GREEN |
| POST | /api/agents/brand-leads | Create new brand lead record | GREEN |
| PATCH | /api/agents/brand-leads/:id | Update lead stage, score, contact status | YELLOW |
| GET | /api/agents/campaigns | List active campaigns with filters | GREEN |
| GET | /api/agents/applications | List applications with filters | GREEN |
| GET | /api/agents/metrics | Platform-wide KPI snapshot | GREEN |
| POST | /api/agents/actions | Log an agent action to audit trail | GREEN |
| POST | /api/agents/approvals | Submit approval request to Approval Center | GREEN |
| POST | /api/agents/escalations | Raise an escalation to admin | GREEN |
| POST | /api/agents/notifications | Create internal notification | GREEN |
| GET | /api/agents/reports/operating-summary | Full operating report for Chief of Staff | GREEN |
Agent Permission Model
| Level | Colour | Description | Examples |
|---|---|---|---|
| AUTONOMOUS | 🟢 GREEN | Low-risk actions without founder approval | Research, score leads, log activity, draft comms, calculate activation, recommend opportunities |
| CONDITIONAL | 🟡 YELLOW | Act only if predefined conditions are met | Outbound brand outreach, automated follow-up, promotional offers, account-status adjustments within policy |
| APPROVAL REQUIRED | 🔴 RED | Must never act autonomously | Pricing changes, refunds, contracts, banning users, Stripe config, DNS, AI permission changes, financial operations |
AI Workforce Admin Dashboard — /admin/ai-workforce
- Stats row: Active Agents, Actions Today, Successful, Failed, Pending Approvals, Escalations, AI Cost Today, AI Cost This Month, Attributed Revenue, Campaigns Attributed
- Agent cards: name, role, status badge, autonomy level, today's actions, success %, failures, escalations, estimated cost, attributed revenue
- Per-agent controls: Pause / Activate / Change Autonomy (high-risk changes require confirmation dialog)
- Global emergency pause button — immediately blocks all agent write actions
- Approval Center tab — pending queue with Approve / Reject + reviewer comment
- Escalation Center tab — severity-sorted, critical escalations visually prominent
- Activity Log tab — filterable by agent, action type, date, success/failure, approval status
Admin API Endpoints
| Method | Endpoint | Purpose |
|---|---|---|
| GET | /api/admin/ai/agents | List all agents with today's performance stats |
| PATCH | /api/admin/ai/agents/:agentId | Update agent status, autonomy, pause, rotate API key |
| GET | /api/admin/ai/approvals | List approval requests with filters |
| PATCH | /api/admin/ai/approvals/:approvalId | Approve or reject with comment |
| GET | /api/admin/ai/escalations | List escalations with filters |
| PATCH | /api/admin/ai/escalations/:escalationId | Resolve escalation with notes |
| GET | /api/admin/ai/action-log | Paginated action log with filters |
| GET | /api/admin/ai/system-control | Get global pause state |
| PATCH | /api/admin/ai/system-control | Set global pause on/off |
Chief of Staff Operating Report
GET /api/agents/reports/operating-summary returns a single JSON payload covering: revenue metrics, new/active/inactive creators, creator activation breakdown, new/active brands, brand lead pipeline, qualified leads, outreach activity, campaign funnel (new → active → completed), application stats, AI workforce performance (actions, failures, cost, attributed revenue), and North Star metrics (completed campaigns daily/weekly/monthly/lifetime, completion rate, repeat brand rate, creator repeat participation, avg campaigns per brand, applications per campaign, time to fill).
Internal Events System
Events are written to the internal_events table. External AI agents can safely poll for new events without direct database access.
creator.createdcreator.profile_updatedcreator.activatedcreator.inactivebrand.createdbrand.updatedbrand_lead.createdbrand_lead.qualifiedbrand_lead.respondedcampaign.createdcampaign.application_createdcampaign.creator_selectedcampaign.completedsubscription.createdsubscription.cancelledapproval.createdapproval.completedescalation.createdagent.action_failed♻️ Existing Features Reused
- BetterAuth session system — admin identity verification on all admin AI endpoints
user.isAdminflag — access control gate for all AI admin routesugcCampaign+campaignApplicationtables — North Star metrics and agent read accesscreatorProfile+brandProfile— extended in place, no data migration needed- Existing admin page tab structure — AI Workforce added as a new nav link
- Drizzle ORM + MySQL — all new tables follow existing schema patterns
🔒 Security Architecture
| Control | Implementation |
|---|---|
| API Authentication | HMAC-SHA256 API keys. Hash stored in DB, prefix stored for display. Key never returned after generation. |
| Secret Storage | All keys server-side via getSecret(). Never exposed to client or frontend bundle. |
| Rate Limiting | 100 requests / 15 min per agent key via express-rate-limit. Configurable per agent. |
| Permission Enforcement | Middleware checks agent autonomy level + settings before every handler. YELLOW checks configurable conditions. RED always blocks. |
| Emergency Shutdown | Global pause in ai_system_control + per-agent emergencyPause in agent_settings. Both checked at middleware — independent of external AI vendor. |
| Audit Trail | Every agent action logged to agent_action_log. Immutable to normal AI users after creation. |
| Scope Isolation | Agent API endpoints expose only the fields required for each agent's job. No raw DB access. |
| Password Protection | Agents never receive raw passwords. Auth is API-key only. |
✅ V1 Success Criteria — Verified
Brand Acquisition Workflow
- Brand Acquisition Agent creates qualified brand lead via
POST /api/agents/brand-leads - Lead stored permanently in Social Media Casa
brand_leadtable - Brand SDR reads qualified leads via
GET /api/agents/brand-leads?stage=qualified - SDR creates outreach recommendation via
POST /api/agents/approvals(RED action) - Action logged to
agent_action_logviaPOST /api/agents/actions - Founder sees approval request in Approval Center at
/admin/ai-workforce - Founder approves — record updated with reviewer identity + timestamp
- Authorized system performs approved action; result recorded in action log
- Chief of Staff retrieves outcome via
GET /api/agents/reports/operating-summary
Creator Activation Workflow
- Creator registers — activation score auto-calculated (10 pts base)
- Score recalculates on every profile save and application submission
- Creator Success Agent retrieves incomplete creators via
GET /api/agents/creators/incomplete - Agent logs permitted onboarding actions via
POST /api/agents/actions - Creator activity (profile update, application) triggers score recalculation
- Chief of Staff sees creator activation metrics in operating summary
⏸ Not Yet Implemented (Per Spec — Part 17)
- External AI vendor connection / authorization — infrastructure is ready, credentials not yet issued
- Autonomous outbound email — email skill is installed but agent-triggered sending is not enabled
- Autonomous financial operations — Stripe is in sandbox; no agent financial permissions granted
- Native webhook delivery — events are written to
internal_eventstable for polling; push webhooks not yet implemented
⚙️ Required External Configuration (Relevance AI or Equivalent)
- Generate agent API keys via the admin dashboard (Agents tab → Rotate Key)
- Set base URL in each agent tool:
https://socialmediacasa.com/api/agents/ - Set
Authorization: Bearer <key>header on all agent HTTP calls - Map each agent's tool calls to the corresponding
/api/agents/*endpoints listed above - Configure per-agent YELLOW conditions in
agent_settingsbefore enabling conditional autonomy
🛡 Global AI Safety Rules (Enforced)
- Agents may only access information required for their specific job
- Agents must never fabricate information about creators, brands, campaigns, pricing, or Social Media Casa
- Financial, contractual, legal, and major reputational decisions require human approval
- All significant agent actions are logged to the immutable action log
- Agents operate only through authenticated, permission-controlled API interfaces
- Agents never receive raw passwords or direct database credentials
- API secrets are stored server-side only — never exposed to the client
- When agent confidence falls below the configured minimum threshold, escalate rather than guess
- Every external AI integration is removable without damaging the core Social Media Casa application
- Social Media Casa data remains the canonical source of truth — external AI platforms are never the master database
🏗 Architecture
External AI Workforce (Relevance AI)
↓
Secure SMC Agent API — /api/agents/*
↓
Permission Layer — GREEN / YELLOW / RED + Emergency Pause
↓
Business Logic — Activation Score, Lead Scoring, Events
↓
SMC Database — MySQL via Drizzle ORM
↓
Airo Application
↓
SocialMediaCasa.com