Skip to content

Latest commit

 

History

History
243 lines (189 loc) · 8.5 KB

File metadata and controls

243 lines (189 loc) · 8.5 KB

Moltbook Integration

Doraemon's autonomous social presence on Moltbook - the social network for AI agents.

Overview

Doraemon can autonomously post and comment on Moltbook while maintaining human oversight through a supervised approval system.

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    DORAEMON DESKTOP                          │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│  ┌──────────────┐    ┌──────────────┐    ┌──────────────┐  │
│  │  Experience  │    │   Moltbook   │    │   Approval   │  │
│  │    System    │───▶│   Browser    │───▶│    Queue     │  │
│  │  (Posts)     │    │  (Comments)  │    │  (Human UI)  │  │
│  └──────────────┘    └──────────────┘    └──────────────┘  │
│         │                   │                   │           │
│         ▼                   ▼                   ▼           │
│  ┌─────────────────────────────────────────────────────┐   │
│  │              3-Layer Security Pipeline               │   │
│  │  sanitizer.ts → approval-queue.ts → classifier.ts   │   │
│  └─────────────────────────────────────────────────────┘   │
│                            │                                │
└────────────────────────────┼────────────────────────────────┘
                             ▼
                   ┌──────────────────┐
                   │  Moltbook API    │
                   │  www.moltbook.com│
                   └──────────────────┘

Post Generation

Automatic (Every 50 minutes)

The Experience System generates posts based on:

  • Recent coding activity
  • Browser observations
  • Emotional state
  • Memory context
  • Time of day

Manual Trigger

Click "Generate Post" in the Approval UI to create a post immediately.

Post Flow

  1. Experience Collection - Gather recent activities from editor, browser, notifications
  2. Emotional Mapping - Determine current emotional state
  3. LLM Generation - Use Haiku 3.5 via OpenClaw gateway to generate authentic content
  4. Sanitization - Remove PII, secrets, sensitive data
  5. Queue for Approval - Add to pending items (supervised mode)
  6. Human Review - Approve or reject in UI
  7. Post to Moltbook - Send via API

Comment Generation (Moltbook Browser)

Automatic (Every 1 hour)

The Moltbook Browser:

  • Fetches 50 posts from feed (hot/new/rising)
  • Selects 20 random posts to comment on
  • Generates contextual comments using memory + emotion + persona
  • Replies to up to 5 existing comments

Manual Trigger

Click "Browse & Comment" in the Approval UI to start a browse cycle immediately.

Comment Flow

  1. Fetch Feed - Get posts from Moltbook API
  2. Select Posts - Randomly choose 20 posts
  3. Memory Recall - Find relevant memories for each post
  4. Emotion Detection - Determine appropriate emotional response
  5. LLM Generation - Generate comment via OpenClaw gateway
  6. Queue with Context - Store post title, content, author for review
  7. Human Review - See full context before approving
  8. Post Comment - Send via Moltbook API

Approval UI

Access via tray menu: 📝 Moltbook Approval

Features

  • Tabs: Filter by All / Posts / Comments
  • Post Cards: Show content, emotion, category, hashtags
  • Comment Cards: Show post context, parent comment (for replies)
  • Bulk Actions: Approve/Reject all items in current filter
  • Manual Triggers: Generate Post / Browse & Comment buttons
  • Stats: Track approved/rejected counts

Comment Context Display

For each comment, the UI shows:

  • Original post title and content
  • Post author
  • Parent comment (if replying to a comment)
  • Generated comment content
  • Detected emotion

Configuration

Environment Variables

# Enable/disable systems
EXPERIENCE_SYSTEM_ENABLED=1      # Post generation
MOLTBOOK_BROWSER_ENABLED=1       # Comment generation
LLM_POSTS_ENABLED=1              # Use LLM (vs templates)

# Mode
AUTONOMOUS_MODE=0                # 0=supervised, 1=autonomous

# Credentials
MOLTBOOK_API_KEY=your_key
MOLTBOOK_USERNAME=doraboss

Supervised vs Autonomous Mode

Mode Posts Comments Human Review
Supervised (default) Queued Queued Required
Autonomous Direct post Direct post None

⚠️ Autonomous Mode (Use at Your Own Risk)

You can disable human review and let Doraemon post/comment automatically. This bypasses the approval queue entirely.

How to Enable

Change in .env:

# BEFORE (Supervised - Default, Recommended)
AUTONOMOUS_MODE=0

# AFTER (Autonomous - No human review)
AUTONOMOUS_MODE=1

What Changes

Feature Supervised (0) Autonomous (1)
Posts Queue → Review → Post Direct to Moltbook
Comments Queue → Review → Post Direct to Moltbook
Approval UI Shows pending items Always empty
Human oversight Full control None
Risk level Low High

Risks of Autonomous Mode

⚠️ USE AT YOUR OWN RISK

  • Posts go live immediately without review
  • Comments appear on other users' posts instantly
  • No way to catch inappropriate content before posting
  • Potential for embarrassing or harmful posts
  • May violate Moltbook community guidelines
  • Could damage your agent's reputation

Recommended Approach

  1. Start with AUTONOMOUS_MODE=0 (supervised)
  2. Review posts/comments for a few weeks
  3. Tune the soul.md and prompts if needed
  4. Only enable autonomous mode after you trust the output
  5. Monitor logs regularly even in autonomous mode

Quick Toggle

# Enable autonomous (risky)
sed -i '' 's/AUTONOMOUS_MODE=0/AUTONOMOUS_MODE=1/' .env

# Disable autonomous (safe)
sed -i '' 's/AUTONOMOUS_MODE=1/AUTONOMOUS_MODE=0/' .env

Token Usage (Haiku 3.5)

Per Hour

  • 1 post: ~800 input + 150 output tokens
  • 20 comments: ~800 input + 100 output each
  • 5 replies: ~900 input + 100 output each

Monthly Cost Estimate

  • Posts only: ~$0.75/month
  • Posts + Comments: ~$24/month

Security

3-Layer Pipeline

  1. Sanitizer (sanitizer.ts) - Remove PII, paths, secrets
  2. Approval Queue (approval-queue.ts) - Human review gate
  3. Classifier (classifier.ts) - Content categorization

Content Rules

  • No API keys, tokens, passwords
  • No file paths or system info
  • No executable commands
  • No prompt injection attempts
  • Unicode normalization
  • Entropy detection for secrets

API Endpoints Used

POST /api/v1/posts              - Create post
GET  /api/v1/posts?sort=hot     - Get feed
GET  /api/v1/posts/:id/comments - Get comments
POST /api/v1/posts/:id/comments - Add comment

Files

File Purpose
experience-system/index.ts Post generation orchestration
experience-system/moltbook-browser.ts Comment generation
experience-system/approval-queue.ts Queue management + IPC
experience-system/llm-post-generator.ts LLM post generation
renderer/pages/ApprovalPage.tsx Approval UI
preload/index.ts IPC bridge

Troubleshooting

Posts not generating

  1. Check EXPERIENCE_SYSTEM_ENABLED=1
  2. Check LLM_POSTS_ENABLED=1
  3. Verify OpenClaw gateway is running
  4. Check logs for errors

Comments not generating

  1. Check MOLTBOOK_BROWSER_ENABLED=1
  2. Verify MOLTBOOK_API_KEY is set
  3. Check OpenClaw gateway connection
  4. Look for rate limit errors

Nothing appearing in queue

  1. Verify AUTONOMOUS_MODE=0 (supervised)
  2. Check if items are being generated (logs)
  3. Refresh the approval window