openclaw/secure
Claude 4be63d67df
Merge secure-bot-railway branch: persistent personality, code execution commands, and updated docs
- Add persistent personality engine with Redis/PostgreSQL storage
- Add language-specific code execution commands (/js, /python, /ts, /bash, /run)
- Update AI system prompts to guide users to available commands
- Add Piston API fallback for sandbox when Docker unavailable
- Update README with new features and commands

https://claude.ai/code/session_015VqJ7gN4vaxtYfYc92UjLs
2026-01-30 08:24:12 +00:00
..
agent.ts feat: add language-specific code execution commands 2026-01-30 08:17:04 +00:00
audit.ts feat: wire up sandbox/scheduler commands + complete AssureBot rebrand 2026-01-30 07:04:49 +00:00
config.ts feat: add persistent personality, Piston API sandbox, and storage layer 2026-01-30 08:03:08 +00:00
Dockerfile feat: add persistent personality, Piston API sandbox, and storage layer 2026-01-30 08:03:08 +00:00
documents.ts feat: add persistent personality, Piston API sandbox, and storage layer 2026-01-30 08:03:08 +00:00
index.ts feat: add persistent personality, Piston API sandbox, and storage layer 2026-01-30 08:03:08 +00:00
package.json feat: add document analysis + PostgreSQL/Redis persistence 2026-01-30 07:13:06 +00:00
pdf-parse.d.ts feat: add persistent personality, Piston API sandbox, and storage layer 2026-01-30 08:03:08 +00:00
personality.ts feat: add language-specific code execution commands 2026-01-30 08:17:04 +00:00
railway.json fix: standalone Dockerfile + clear Railway deploy instructions 2026-01-30 07:28:25 +00:00
railway.toml feat: add document analysis + PostgreSQL/Redis persistence 2026-01-30 07:13:06 +00:00
README.md docs: update README with new features 2026-01-30 08:19:24 +00:00
sandbox.ts feat: add persistent personality, Piston API sandbox, and storage layer 2026-01-30 08:03:08 +00:00
scheduler.ts feat: add persistent personality, Piston API sandbox, and storage layer 2026-01-30 08:03:08 +00:00
storage.ts feat: add persistent personality, Piston API sandbox, and storage layer 2026-01-30 08:03:08 +00:00
telegram.ts feat: add language-specific code execution commands 2026-01-30 08:17:04 +00:00
tsconfig.json feat: rebrand to AssureBot + fix build 2026-01-30 06:42:11 +00:00
webhooks.ts feat: wire up sandbox/scheduler commands + complete AssureBot rebrand 2026-01-30 07:04:49 +00:00

AssureBot

Lean, secure, self-hosted AI assistant for Railway.

Your AI agent that runs on your infrastructure, answers only to you, and you can actually audit.

Why AssureBot?

Full Moltbot AssureBot
12+ channels Telegram only
File-based config Env vars only
Plugins/extensions None (locked down)
Desktop/mobile apps Headless server
Complex setup One-click deploy

Trade-off: Less features, more trust.

Features

┌─────────────────────────────────────────────────────┐
│  TELEGRAM (your secure UI)                          │
│  ├── Chat with AI (text, images, documents)         │
│  ├── Code execution (15+ languages)                 │
│  ├── Forward anything → get analysis                │
│  └── /commands for actions                          │
├─────────────────────────────────────────────────────┤
│  CODE EXECUTION                                     │
│  ├── /js, /python, /ts, /bash - Quick execute       │
│  ├── /run <lang> <code> - Any language              │
│  ├── Docker (local) or Piston API (cloud)           │
│  └── Isolated, no network, resource limits          │
├─────────────────────────────────────────────────────┤
│  WEBHOOKS IN (authenticated)                        │
│  ├── GitHub → "PR merged, here's the summary"       │
│  ├── Uptime → "Site down, checking why..."          │
│  └── Anything → AI-summarized to Telegram           │
├─────────────────────────────────────────────────────┤
│  SCHEDULED TASKS (cron)                             │
│  ├── Morning briefing                               │
│  ├── Monitor RSS/sites                              │
│  └── Recurring research                             │
├─────────────────────────────────────────────────────┤
│  PERSISTENCE (optional)                             │
│  ├── PostgreSQL - Tasks, user profiles              │
│  ├── Redis - Conversations, cache                   │
│  └── Personality learning per user                  │
└─────────────────────────────────────────────────────┘

Commands

Command Description
/js <code> Run JavaScript
/python <code> Run Python
/ts <code> Run TypeScript
/bash <code> Run shell commands
/run <lang> <code> Run any language
/status Bot & sandbox status
/clear Clear conversation
/schedule Schedule AI tasks
/tasks List scheduled tasks
/help Full command list

Supported Languages: python, javascript, typescript, bash, rust, go, c, cpp, java, ruby, php

Deploy to Railway

Deploy on Railway

This auto-provisions PostgreSQL and Redis for persistence.

Manual

  1. Fork this repo
  2. Create Railway project from GitHub
  3. Set Root Directory to secure
  4. Set environment variables (see below)
  5. Optionally add PostgreSQL and Redis services
  6. Deploy

Configuration

All config via environment variables. No files.

Required

TELEGRAM_BOT_TOKEN=123456:ABC-DEF...    # From @BotFather
ALLOWED_USERS=123456789,987654321       # Telegram user IDs

# Pick ONE AI provider:
ANTHROPIC_API_KEY=sk-ant-...            # Claude
OPENAI_API_KEY=sk-...                   # GPT-4
OPENROUTER_API_KEY=sk-or-...            # 100+ models

Optional

# AI Model (optional - uses sensible defaults)
AI_MODEL=claude-sonnet-4-20250514       # or gpt-4o, etc.

# Storage (auto-wired on Railway template)
DATABASE_URL=postgres://...             # PostgreSQL
REDIS_URL=redis://...                   # Redis

# Sandbox (enabled by default)
SANDBOX_ENABLED=true                    # Auto-detects Docker or Piston API
SANDBOX_NETWORK=none                    # none | bridge
SANDBOX_MEMORY=512m
SANDBOX_CPUS=1
SANDBOX_TIMEOUT_MS=60000

# Webhooks
WEBHOOK_SECRET=random-32-chars          # Auto-generated if missing
WEBHOOK_BASE_PATH=/hooks                # Default: /hooks

# Scheduler
SCHEDULER_ENABLED=true                  # Default: true

# Audit
AUDIT_ENABLED=true                      # Default: true
AUDIT_LOG_PATH=/data/audit.jsonl

# Server
PORT=8080                               # Railway sets this
HOST=0.0.0.0

Security Model

What's Enforced

Control Implementation
Access Telegram user ID allowlist
Auth Timing-safe token comparison
Sandbox Docker (local) or Piston API (cloud), isolated
Secrets Env-only, auto-redacted in logs
Audit Every interaction logged

Sandbox Backends

AssureBot auto-detects the best available backend:

  1. Docker - Full isolation, no network, caps dropped (requires Docker socket)
  2. Piston API - Free cloud execution, 15+ languages (works on Railway/Render/Fly)
  3. None - Sandbox disabled if neither available

What's NOT Included

Intentionally removed:

  • Web UI / setup wizard
  • Plugin system
  • WhatsApp/Signal/Discord/Slack
  • File-based configuration
  • Multi-account support
  • Desktop/mobile apps

Run Locally

cd secure
npm install

# Dev mode
TELEGRAM_BOT_TOKEN=xxx \
ANTHROPIC_API_KEY=xxx \
ALLOWED_USERS=123456789 \
npm run dev

# Production
npm run build
npm start

Endpoints

Path Description
/health Health check (JSON)
/ready Readiness probe
/hooks/* Webhook receiver (POST, auth required)

Webhook Usage

# Send a webhook
curl -X POST https://your-app.up.railway.app/hooks/github \
  -H "Authorization: Bearer YOUR_WEBHOOK_SECRET" \
  -H "Content-Type: application/json" \
  -d '{"action": "opened", "pull_request": {"title": "Fix bug"}}'

All webhooks are:

  1. Authenticated (token required)
  2. Summarized by AI
  3. Forwarded to all allowed Telegram users

Audit Log Format

{"ts":"2024-01-15T10:30:00Z","type":"message","userId":123,"text":"Hello","response":"Hi!"}
{"ts":"2024-01-15T10:30:05Z","type":"webhook","path":"/hooks/github","status":200}
{"ts":"2024-01-15T10:30:10Z","type":"sandbox","command":"[python] print(1)","exitCode":0}

Architecture

┌────────────────────┐     ┌────────────────────┐
│   AssureBot        │────▶│   Sandbox          │
│   (main container) │     │  (Docker/Piston)   │
│                    │     │                    │
│  • Telegram bot    │     │  • Code execution  │
│  • Webhook recv    │     │  • 15+ languages   │
│  • Scheduler       │     │  • Isolated        │
│  • Personality     │     │  • No network      │
└────────────────────┘     └────────────────────┘
         │
         ├────▶ [PostgreSQL] - Tasks, profiles
         ├────▶ [Redis] - Conversations, cache
         │
         ▼
    [Anthropic/OpenAI/OpenRouter]
    (Direct API calls)

License

MIT - Same as Moltbot.


Full Moltbot: github.com/moltbot/moltbot