Social Media Casa

AI Workforce V1 — Completion Report

Social Media Casa · August 15, 2026 · Confidential — Admin Only

✅ V1 Infrastructure Complete

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 / ChangeTypeNotes
ai_agentNew table4 agents seeded: Chief of Staff, Brand Acquisition Manager, Brand SDR, Creator Success Manager
agent_action_logNew tableImmutable audit log — every meaningful AI action recorded
agent_approvalNew tablePending / approved / rejected / expired approval requests
agent_escalationNew tableSeverity-ranked escalations: informational → critical
agent_performanceNew tablePer-agent reporting period stats + attributed revenue
agent_settingsNew tablePer-agent autonomy config, rate limits, approval requirements
ai_system_controlNew tableGlobal emergency pause with audit trail
brand_leadNew tableAI-discovered brand prospects with full pipeline + lead scoring
internal_eventsNew tablePollable event log for external AI consumers
creator_profileExtendedAdded: activationScore, activationStatus, creatorStatus, verificationStatus, lastActiveAt, phone, tiktokUrl, instagramUrl, youtubeUrl, otherSocialUrl
brand_profileExtendedAdded: brandStatus, totalCampaigns, activeCampaigns, completedCampaigns, totalSpend, lastActiveAt, companySize, companyDescription, socialUrls

Creator Activation Score

Auto-calculates on profile save and application submission. Maximum score: 100.

EventPoints
Account created10
Profile image uploaded5
Bio completed10
Niche selected10
At least one social account connected15
Portfolio / examples uploaded20
Opportunity viewed5
First application submitted15
First campaign completed10

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.

MethodEndpointPurposeAutonomy
GET/api/agents/creator/:idFetch creator profile + activation scoreGREEN
GET/api/agents/creators/incompleteList creators with activation score < 80GREEN
GET/api/agents/creators/inactiveList creators inactive > 30 daysGREEN
GET/api/agents/brand/:idFetch brand profile + campaign statsGREEN
GET/api/agents/brand-leadsList brand leads with filters + paginationGREEN
POST/api/agents/brand-leadsCreate new brand lead recordGREEN
PATCH/api/agents/brand-leads/:idUpdate lead stage, score, contact statusYELLOW
GET/api/agents/campaignsList active campaigns with filtersGREEN
GET/api/agents/applicationsList applications with filtersGREEN
GET/api/agents/metricsPlatform-wide KPI snapshotGREEN
POST/api/agents/actionsLog an agent action to audit trailGREEN
POST/api/agents/approvalsSubmit approval request to Approval CenterGREEN
POST/api/agents/escalationsRaise an escalation to adminGREEN
POST/api/agents/notificationsCreate internal notificationGREEN
GET/api/agents/reports/operating-summaryFull operating report for Chief of StaffGREEN

Agent Permission Model

LevelColourDescriptionExamples
AUTONOMOUS🟢 GREENLow-risk actions without founder approvalResearch, score leads, log activity, draft comms, calculate activation, recommend opportunities
CONDITIONAL🟡 YELLOWAct only if predefined conditions are metOutbound brand outreach, automated follow-up, promotional offers, account-status adjustments within policy
APPROVAL REQUIRED🔴 REDMust never act autonomouslyPricing 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

MethodEndpointPurpose
GET/api/admin/ai/agentsList all agents with today's performance stats
PATCH/api/admin/ai/agents/:agentIdUpdate agent status, autonomy, pause, rotate API key
GET/api/admin/ai/approvalsList approval requests with filters
PATCH/api/admin/ai/approvals/:approvalIdApprove or reject with comment
GET/api/admin/ai/escalationsList escalations with filters
PATCH/api/admin/ai/escalations/:escalationIdResolve escalation with notes
GET/api/admin/ai/action-logPaginated action log with filters
GET/api/admin/ai/system-controlGet global pause state
PATCH/api/admin/ai/system-controlSet 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.isAdmin flag — access control gate for all AI admin routes
  • ugcCampaign + campaignApplication tables — North Star metrics and agent read access
  • creatorProfile + 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

ControlImplementation
API AuthenticationHMAC-SHA256 API keys. Hash stored in DB, prefix stored for display. Key never returned after generation.
Secret StorageAll keys server-side via getSecret(). Never exposed to client or frontend bundle.
Rate Limiting100 requests / 15 min per agent key via express-rate-limit. Configurable per agent.
Permission EnforcementMiddleware checks agent autonomy level + settings before every handler. YELLOW checks configurable conditions. RED always blocks.
Emergency ShutdownGlobal pause in ai_system_control + per-agent emergencyPause in agent_settings. Both checked at middleware — independent of external AI vendor.
Audit TrailEvery agent action logged to agent_action_log. Immutable to normal AI users after creation.
Scope IsolationAgent API endpoints expose only the fields required for each agent's job. No raw DB access.
Password ProtectionAgents never receive raw passwords. Auth is API-key only.

✅ V1 Success Criteria — Verified

Brand Acquisition Workflow

  1. Brand Acquisition Agent creates qualified brand lead via POST /api/agents/brand-leads
  2. Lead stored permanently in Social Media Casa brand_lead table
  3. Brand SDR reads qualified leads via GET /api/agents/brand-leads?stage=qualified
  4. SDR creates outreach recommendation via POST /api/agents/approvals (RED action)
  5. Action logged to agent_action_log via POST /api/agents/actions
  6. Founder sees approval request in Approval Center at /admin/ai-workforce
  7. Founder approves — record updated with reviewer identity + timestamp
  8. Authorized system performs approved action; result recorded in action log
  9. Chief of Staff retrieves outcome via GET /api/agents/reports/operating-summary

Creator Activation Workflow

  1. Creator registers — activation score auto-calculated (10 pts base)
  2. Score recalculates on every profile save and application submission
  3. Creator Success Agent retrieves incomplete creators via GET /api/agents/creators/incomplete
  4. Agent logs permitted onboarding actions via POST /api/agents/actions
  5. Creator activity (profile update, application) triggers score recalculation
  6. 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_events table for polling; push webhooks not yet implemented

⚙️ Required External Configuration (Relevance AI or Equivalent)

  1. Generate agent API keys via the admin dashboard (Agents tab → Rotate Key)
  2. Set base URL in each agent tool: https://socialmediacasa.com/api/agents/
  3. Set Authorization: Bearer <key> header on all agent HTTP calls
  4. Map each agent's tool calls to the corresponding /api/agents/* endpoints listed above
  5. Configure per-agent YELLOW conditions in agent_settings before enabling conditional autonomy

🛡 Global AI Safety Rules (Enforced)

  1. Agents may only access information required for their specific job
  2. Agents must never fabricate information about creators, brands, campaigns, pricing, or Social Media Casa
  3. Financial, contractual, legal, and major reputational decisions require human approval
  4. All significant agent actions are logged to the immutable action log
  5. Agents operate only through authenticated, permission-controlled API interfaces
  6. Agents never receive raw passwords or direct database credentials
  7. API secrets are stored server-side only — never exposed to the client
  8. When agent confidence falls below the configured minimum threshold, escalate rather than guess
  9. Every external AI integration is removable without damaging the core Social Media Casa application
  10. 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

Social Media Casa — AI Workforce V1 Completion ReportAugust 15, 2026 · Confidential
← Back to Dashboard