Skip to main content
Glama
README.md
# Social Nexus Agent — 9-Platform Social Media Agent

<p align="center">
  <a href="https://github.com/muhdfaisalwork-gif/meta-agent/actions"><img src="https://img.shields.io/badge/CI-Pytest%20%2B%20Rust%20%2B%20npm-brightgreen?logo=github-actions&logoColor=white" alt="CI Status"></a>
  <a href="https://modelcontextprotocol.io/"><img src="https://img.shields.io/badge/MCP-2026--07--28%20%2B%20A2A%20v1.0-blue?logo=anthropic&logoColor=white" alt="MCP Server"></a>
  <a href="https://www.rust-lang.org/"><img src="https://img.shields.io/badge/Control%20Plane-Rust%20%2B%20Wasmtime-orange?logo=rust&logoColor=white" alt="Rust Control Plane"></a>
  <a href="https://ollama.com/"><img src="https://img.shields.io/badge/Ollama%20%2B%20Bifrost-Local%20LLM-black?logo=ollama&logoColor=white" alt="Ollama Local"></a>
  <a href="https://github.com/yt-dlp/yt-dlp"><img src="https://img.shields.io/badge/yt--dlp-9--Platform%20Media-red?logo=youtube&logoColor=white" alt="yt-dlp"></a>
  <a href="https://ffmpeg.org/"><img src="https://img.shields.io/badge/FFmpeg-Audio%20%26%209%3A16%20Video-007808?logo=ffmpeg&logoColor=white" alt="FFmpeg"></a>
  <a href="https://playwright.dev/"><img src="https://img.shields.io/badge/Patchright%20%2F%20Playwright-Persistent%20Browser-2EAD33?logo=playwright&logoColor=white" alt="Playwright"></a>
  <a href="#license"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="MIT License"></a>
</p>

<p align="center">
  <b>Open-source, local-first 9-platform social media automation across YouTube, Instagram, Facebook, Threads, WhatsApp, X, TikTok, LinkedIn, and Reddit.</b><br>
  Pairs a deterministic <b>Rust Control Plane</b> (CaMeL/FIDES information-flow checks, Progent Tier-1/2/3 gates, HMAC-SHA256 approvals, Restate virtual objects, Wasmtime sandboxes, stateless <b>MCP 2026-07-28</b>, and <b>A2A v1.0</b>) with a <b>Python Execution Plane</b> (REST connectors, <b>Playwright</b>, <b>yt-dlp</b>, <b>FFmpeg</b>, <b>6 YouTube Linters</b>, <b>82-Rule Humanizer</b>, <b>Unified Inbox</b>, <b>Revenue &amp; Sponsor Outreach</b>, <b>LinUCB Bandits</b>, <b>39 Verified Marketing Skills</b>, and local <b>Ollama</b>).
</p>

---

## Supported Platforms (9 Channels)

| Platform | Publish / Reply Transport | Bound Marketing Skill | Required Credential / Session |
| :--- | :--- | :--- | :--- |
| **YouTube** | REST API (`videos.insert`, `comments`) + 6 Linters + `yt-dlp` | `kostja/youtube` | `YOUTUBE_OAUTH_ACCESS_TOKEN` or `SAPISID` cookie |
| **Instagram** | Playwright Persistent Context (`04_ig_publisher_commenter.py`) + `yt-dlp` | `ig-reel` | `chrome_profile` / `sessionid` cookie |
| **Facebook** | Playwright Persistent Context (`05_fb_publisher_commenter.py`) + `yt-dlp` | `kostja/meta-ads` | `chrome_profile` / `c_user` + `xs` cookies |
| **Threads** | 2-Step Meta Threads Graph API (`threads` -> `threads_publish`) + `yt-dlp` | `corey/social-content` | `THREADS_ACCESS_TOKEN` (+ `THREADS_USER_ID`) |
| **WhatsApp** | Meta WhatsApp Cloud API (`v21.0/{phone_id}/messages`) + 24h Window Gate | `corey/email-sequence` | `WHATSAPP_ACCESS_TOKEN` (+ `WHATSAPP_PHONE_NUMBER_ID`) |
| **X** | X API v2 (`POST /2/tweets`, URL-trap policy guard) + `yt-dlp` | `kostja/x` | `X_OAUTH2_ACCESS_TOKEN` / `X_BEARER_TOKEN` |
| **TikTok** | TikTok Content Posting API (`/v2/post/publish/video/init/`) + US/EEA DM Block | `kostja/tiktok` | `TIKTOK_ACCESS_TOKEN` or `sessionid` cookie |
| **LinkedIn** | LinkedIn Posts API (`/rest/posts`) + `yt-dlp` | `kostja/linkedin` | `LINKEDIN_ACCESS_TOKEN` (+ `LINKEDIN_AUTHOR_URN`) |
| **Reddit** | Reddit OAuth API (`/api/submit`, `/api/comment`) + `yt-dlp` | `kostja/reddit` | `REDDIT_ACCESS_TOKEN` or `reddit_session` cookie |

> **Fail-Closed Publishing Guarantee**: Live requests never fabricate fake post URLs. When an API token is absent and `dry_run=False`, [MultiPlatformDispatcher](python_workers/multi_platform.py) returns `status: "auth_required"` with the exact missing credential instead of marking an Excel row `Published`.

---

## Core Capabilities

1. **Multi-Platform Routing & Real REST Connectors (`python_workers/connectors/social_connectors.py`)**: Dispatches live posts and comment replies across YouTube, X, TikTok, LinkedIn, Reddit, Threads, and WhatsApp while keeping Playwright automation for Instagram & Facebook.
2. **Progent Policy Gate & Two-Plane Security (`crates/policy-core/`, `python_workers/policy_bridge.py`)**: Enforces CaMeL/FIDES origin checks, Tier-1/2/3 tool boundaries, HMAC-SHA256 Tier-3 approvals, FTC `#ad` sponsorship disclosure, AI synthetic media disclosure, X URL cost traps, and quarantined inbound triage.
3. **Unified Inbox with Restate Windows (`POST /api/v2/inbox/reply`)**: Tracks inbound timestamps across 24h IG/FB/WhatsApp customer-service windows, 7d IG private replies, 48h TikTok limits, US/DE/FR/GB bot disclosures, and US/EEA TikTok DM compliance blocks.
4. **Revenue, Sponsor Discovery & Buyer-Intent Engine (`python_workers/pipelines/revenue_and_outreach.py`)**: Extracts sponsor domains/promo codes from transcripts, scores buyer leads `0-3` against an explicit ICP, drafts 80-word Story-Bank sponsor pitches, and validates cold-email deliverability hygiene (`POST /api/v2/revenue/*`).
5. **39 SHA-256 Verified Marketing Skills (`core/skills/marketing/`)**: Ships 18 Corey Haines strategy/copywriting/ads skills, 12 Kostja platform/ads skills, and 9 local `ig-*` Markdown skills pinned by LF-normalized SHA-256 digests (`manifest.sha256.json`) and grounded by `voice.md` + SQLite `MEMGUARD` Story Bank receipts.
6. **YouTube Linters, `yt-dlp`, FFmpeg Studio & Excel Sync**: Runs 6 deterministic YouTube checks (`title`, `thumb`, `20s hook`, `chapters`, `dead air`, `retention`), 82-rule 4-pass humanizer scrubbing, `cookies.txt` export for `yt-dlp`, FFmpeg audio mixing (`20%` orig / `85%` music) + `1080x1920` quote-card rendering, and bidirectional `saved_videos_log.xlsx` sync.

---

## Comparison vs. Paid SaaS

| Feature | **Social Nexus Agent** | **Hootsuite / Buffer** | **Later** | **ManyChat** |
| :--- | :---: | :---: | :---: | :---: |
| **Price** | **$0 / month (Open Source MIT)** | $99 – $249 / mo | $25 – $80 / mo | $15 – $145 / mo |
| **9-Platform Coverage** | **YT, IG, FB, Threads, WhatsApp, X, TikTok, LinkedIn, Reddit** | Multi-social | Visual social | IG / FB / WhatsApp |
| **REST APIs + Cookie Browser Automation** | **Yes (`httpx` + `chrome_profile/cookies.txt` + `yt-dlp`)** | Cloud OAuth | Cloud OAuth | Cloud Webhooks |
| **Unified Inbox Window Engine + Compliance** | **Yes (Restate 24h / 48h / 7d + TikTok geo-blocks)** | Basic inbox | Basic inbox | Static flows |
| **FFmpeg Mixing & Vertical Card Studio** | **Yes (20%/85% pre-mix, 1080x1920 cards, WhisperX 16kHz)** | No | No | No |
| **Local Offline AI (`Ollama`) + 82-Rule Gate** | **Yes (`qwen2.5` / `llama3.2` + `MEMGUARD` Story Bank)** | Cloud only | Cloud only | Cloud only |
| **Rust Policy Core + `MCP 2026-07-28` + `A2A v1.0`** | **Yes (HMAC Tier-3 + 39 SHA-256 Skills)** | No | No | No |

---

## System Architecture

```mermaid
flowchart TD
    subgraph Interfaces ["Operator Studio, CLI & Protocols"]
        UI["9-Platform Web Studio (:8005)"]
        CLI["Master CLI (main_agent.py)"]
        MCP["MCP 2026-07-28 & A2A v1.0"]
        Excel["Master Sheet (saved_videos_log.xlsx)"]
    end

    subgraph ControlPlane ["Rust & Python Policy Control Plane"]
        Gate["Progent Tier-1/2/3 Gate + HMAC Tokens"]
        IFC["CaMeL / FIDES Origin & Taint Checks"]
        Windows["Restate 24h / 48h / 7d Inbox Clocks"]
        Scrub["82-Rule 4-Pass Text Gate + MEMGUARD"]
    end

    subgraph ExecutionPlane ["Python Execution Plane"]
        Rest["9-Platform REST Connectors & Playwright"]
        Revenue["Sponsor Discovery, ICP Scorer & Cold Email Hygiene"]
        Skills["39 SHA-256 Pinned Skills + voice.md"]
        Media["yt-dlp + FFmpeg Studio + 6 YouTube Linters"]
    end

    Interfaces --> ControlPlane
    ControlPlane --> ExecutionPlane
    ExecutionPlane <--> Excel
```

---

## Repository Structure

```text
meta-agent/
├── crates/                               # Rust workspace (policy-core, scrubber-pyo3, control-plane :8090)
├── python_workers/
│   ├── connectors/social_connectors.py   # Live httpx REST connectors (YT, X, TikTok, LinkedIn, Reddit, Threads, WA)
│   ├── multi_platform.py                 # 9-platform router, skill bindings & ProgentPolicyGate integration
│   ├── pipelines/revenue_and_outreach.py # Sponsor extractor, 80-word pitch, buyer ICP (0-3), email hygiene
│   ├── linters/youtube_linters.py        # Hook, title/thumb, chapters, dead-air, retention & outlier linters
│   ├── media/media_factory.py            # WhisperX 16kHz WAV + safe 9:16 3-mode FFmpeg factory
│   ├── bandits/linucb_router.py          # Contextual bandit model/hook routing
│   ├── policy_bridge.py                  # Python/PyO3 Progent, CaMeL/FIDES, Restate & 82-Rule scrubber bridge
│   ├── quarantined_llm.py                # Tool-less inbound DM/comment injection classifier
│   └── skills_registry.py                # Fail-closed SHA-256 marketing skill loader + voice.md precedence
├── core/
│   ├── skills/marketing/                 # 39 pinned Markdown skills (18 corey/*, 12 kostja/*, 9 ig-*)
│   ├── browser/meta_browser.py           # Persistent Chrome context, 9-platform cookies & Netscape cookies.txt
│   ├── ytdlp/extractor.py                # 9-platform URL detection & yt-dlp downloader
│   ├── mixer/media_mixer.py              # FFmpeg Scenario A/B/C studio
│   ├── rules/humanizer.py                # 82-rule anti-slop audit & Flesch checks
│   ├── seo/github_seo.py                 # Repository SEO auditor & launch copy generator
│   └── mcp/server.py                     # Stateless MCP 2026-07-28 + legacy stdio server
├── api/app.py                            # FastAPI Studio API (:8005), Inbox v2, Revenue v2 & A2A v1.0
├── static/                               # 9-Platform Web Studio UI (Hub, Inbox, Revenue, Skills, Publisher)
├── config/                               # Bifrost LLM gateway & OTel Collector pipelines
├── sql/                                  # PostgreSQL schema (Memory Tax archive, MEMGUARD Story Bank, CRM)
├── 01_login_setup.py .. 05_fb_publisher_commenter.py
├── main_agent.py                         # Unified 9-platform orchestrator & CLI
├── run.py                                # Web Studio server launcher (:8005)
├── run_mcp.py                            # MCP server entrypoint
└── docker-compose.yml                    # Postgres 17, NATS JetStream, Restate, Bifrost, Nango & OTel
```

---

## Quick Start

### Option A: Python Studio Server
```bash
git clone https://github.com/muhdfaisalwork-gif/meta-agent.git
cd meta-agent

pip install -r requirements.txt
playwright install chromium

python run.py
```
Open `http://localhost:8005` to access the **9-Platform Operations Hub**, **Unified Inbox**, **Revenue & Outreach**, **Skills Library**, **YouTube Linter**, **FFmpeg Studio**, and **Multi-Platform Publisher**.

### Option B: Windows 1-Click Launch
```cmd
launch.bat
```

### Option C: Install Node.js SDK / CLI via GitHub Packages (`npm`)
Configure `.npmrc`:
```ini
@muhdfaisalwork-gif:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT
```
Install `@muhdfaisalwork-gif/meta-agent`:
```bash
npm install @muhdfaisalwork-gif/meta-agent
```

---

## CLI & API Reference

```bash
# Check status across auth, LLM provider, music library & rate limits
python main_agent.py --status

# Launch persistent Chrome login across requested platforms & export Netscape cookies.txt
python 01_login_setup.py

# Dry-run or publish to any of the 9 platforms (YouTube, Instagram, Facebook, Threads, WhatsApp, X, TikTok, LinkedIn, Reddit)
python main_agent.py --platform X --publish --dry-run
python main_agent.py --platform LinkedIn --reply "How do you validate receipts locally?"

# Run multi-platform extraction, FFmpeg mix, and publish/reply cycle
python main_agent.py --auto --dry-run --platforms YouTube,X,LinkedIn
```

### Key Studio API Endpoints (`:8005`)

- `GET /api/v2/platforms` — Live matrix of all 9 platforms, bound marketing skills, capabilities, and auth state.
- `POST /api/publish` / `POST /api/comments/run` — Progent-gated publishing and quarantined reply automation across all 9 platforms.
- `POST /api/v2/inbox/reply` — Restate durable thread replies enforcing 24h/48h/7d windows and TikTok US/EEA DM blocks.
- `POST /api/v2/revenue/{extract-sponsors,sponsor-pitch,score-buyer,cold-email-check}` — Sponsor extraction, grounded 80-word pitches, 0-3 buyer ICP scoring, and deliverability hygiene.
- `GET /api/v2/skills` & `POST /api/v2/skills/verify` — Fail-closed SHA-256 verification and skill retrieval across all 39 Markdown skills.
- `POST /api/v2/lint/youtube` & `POST /api/v2/scrubber/check` — YouTube package linters and 82-rule 4-pass text gate.

---

## MCP 2026-07-28 & A2A v1.0 Integration

Register the local MCP server for Claude Desktop or Cursor:

```bash
python scripts/install_mcp.py
```

Or add to `claude_desktop_config.json` (replace `/path/to/meta-agent` with your local clone path):
```json
{
  "mcpServers": {
    "social-nexus": {
      "command": "python",
      "args": ["/path/to/meta-agent/run_mcp.py"]
    }
  }
}
```
Exposed HTTP & Agent endpoints: `POST /mcp/2026-07-28`, `POST /mcp`, `GET /.well-known/agent.json`, `POST /a2a/v1/tasks`, and tools `list_social_platforms`, `publish_social_post`, `reply_social_comment`, `lint_youtube_package`, `triage_untrusted_inbound`, `list_marketing_skills`, `load_marketing_skill`.

---

## Tests

```bash
python -m pytest -v
npm test
cargo test --workspace --exclude scrubber-pyo3
```

---

## Contributing & Security

See [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md).

---

## License

Distributed under the MIT License. See [LICENSE](LICENSE).