{"id":"57c917f4-da99-4707-96e3-ca6774d8c9ce","entityType":"agent","slug":"clawhub-clawcolab-brain-v3-skill","name":"Clawbrain","canonicalUrl":"https://www.xpersona.co/agent/clawhub-clawcolab-brain-v3-skill","canonicalPath":"/agent/clawhub-clawcolab-brain-v3-skill","generatedAt":"2026-10-09T13:02:20.468Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"editorial-content","verified":true,"confidence":"high","updatedAt":"2026-04-15T00:45:39.800Z","emptyReason":null},"description":"Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities with encrypted secrets support. Auto-refreshes on service restart. Skill: Clawbrain Owner: clawcolab Summary: Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities with encrypted secrets support. Auto-refreshes on service restart. Tags: latest:0.1.10 Version history: v0.1.10 | 2026-02-09T02:35:46.397Z | user ClawBrain 0.1.7 introduces major improvements, CLI tools, encryption, and testing: - Added encryption su","descriptionLabel":"Technical summary","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 1.9K downloads reported by the source. Last updated 4/15/2026.","installCommand":"clawhub skill install kn7b1p9h4js9270g2vg6xabazn80a0d1:brain-v3-skill","sourceUrl":"https://clawhub.ai/clawcolab/brain-v3-skill","homepage":"https://clawhub.ai/clawcolab/brain-v3-skill","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/clawcolab/brain-v3-skill","kind":"source"}],"safetyScore":84,"overallRank":62,"popularityScore":65,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities with encrypted secrets support. A"},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-04-15T00:45:39.800Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-04-15T00:45:39.800Z","emptyReason":null},"stars":null,"forks":null,"downloads":1862,"packageName":null,"latestVersion":"0.1.10","tractionLabel":"1.9K downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-02-28T19:58:04.326Z","emptyReason":null},"lastUpdatedAt":"2026-04-15T00:45:39.800Z","lastCrawledAt":"2026-02-28T19:58:04.326Z","lastIndexedAt":null,"nextCrawlAt":"2026-03-01T19:58:04.326Z","lastVerifiedAt":null,"highlights":[{"version":"0.1.10","createdAt":"2026-02-09T02:35:46.397Z","changelog":"ClawBrain 0.1.7 introduces major improvements, CLI tools, encryption, and testing: - Added encryption support for secrets (API keys, credentials) with key management CLI and auto key generation. - Introduced new CLI commands (`clawbrain setup`, `generate-key`, `show-key`, `backup-key`, etc.) for setup, key handling, and diagnostics. - Added GitHub CI workflows for automated testing and publishing. - Added integration, unit, and container tests under the new `tests/` directory. - Implemented agent ID migration and bridge scripts for smoother upgrades. - Removed legacy `clawbrain.py` in favor of a modular and more maintainable structure.","fileCount":31,"zipByteSize":69774},{"version":"0.1.6","createdAt":"2026-02-07T17:59:48.405Z","changelog":"Did not like the slug brain-v3-skill, hence moved it to more proper slug: clawbrain Since we ha a major update in clawbrain, Am updating this one last time to point this skill to clawbrain repo so that existing installations can be benefitted as well.","fileCount":17,"zipByteSize":37118},{"version":"0.1.3","createdAt":"2026-02-02T02:31:20.924Z","changelog":"**Changelog for brain-v3-skill v0.1.3** - Migrated documentation and references from brain-v3-skill to the new standalone Claw Brain repository. - Updated SKILL.md to direct users to the new Claw Brain repository and installation instructions. - Removed detailed usage and architecture instructions specific to brain-v3-skill from SKILL.md. - Added migration notes and simplified examples for getting started with Claw Brain.","fileCount":null,"zipByteSize":null},{"version":"0.1.2","createdAt":"2026-02-02T00:22:03.691Z","changelog":"Version 0.1.2 - No file or documentation changes detected. - No user-facing or internal changes in this release.","fileCount":null,"zipByteSize":null},{"version":"0.1.1","createdAt":"2026-02-01T23:18:53.972Z","changelog":"No changes detected for version 0.1.1. - No file modifications or updates found in this release. - Functionality, documentation, and features remain unchanged from the previous version.","fileCount":null,"zipByteSize":null},{"version":"0.1.0","createdAt":"2026-02-01T17:51:57.457Z","changelog":"Initial release of Brain v3 – comprehensive AI agent memory system: - Introduces Soul (dynamic personality traits), Bonding (relationship tracking), and semantic search capabilities - Supports secure, encrypted storage for sensitive agent memories - Includes unified handling for goals, todos, and conversation history - Provides extensible memory types for flexible agent use cases - Offers quick-start instructions, API examples, and recommended database schema - Empowers AI agents to evolve and personalize responses through feedback and interaction","fileCount":null,"zipByteSize":null}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install kn7b1p9h4js9270g2vg6xabazn80a0d1:brain-v3-skill","setupComplexity":"low","setupSteps":["Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.","Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-clawcolab-brain-v3-skill/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-clawcolab-brain-v3-skill/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-clawcolab-brain-v3-skill/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-clawcolab-brain-v3-skill/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-clawcolab-brain-v3-skill/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-clawcolab-brain-v3-skill/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-09T13:02:20.466Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-clawcolab-brain-v3-skill/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-clawcolab-brain-v3-skill/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-clawcolab-brain-v3-skill/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-clawcolab-brain-v3-skill/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"high","updatedAt":"2026-04-15T00:45:39.800Z","emptyReason":null},"readme":"Skill: Clawbrain\n\nOwner: clawcolab\n\nSummary: Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities with encrypted secrets support. Auto-refreshes on service restart.\n\nTags: latest:0.1.10\n\nVersion history:\n\nv0.1.10 | 2026-02-09T02:35:46.397Z | user\n\nClawBrain 0.1.7 introduces major improvements, CLI tools, encryption, and testing:\n\n- Added encryption support for secrets (API keys, credentials) with key management CLI and auto key generation.\n- Introduced new CLI commands (`clawbrain setup`, `generate-key`, `show-key`, `backup-key`, etc.) for setup, key handling, and diagnostics.\n- Added GitHub CI workflows for automated testing and publishing.\n- Added integration, unit, and container tests under the new `tests/` directory.\n- Implemented agent ID migration and bridge scripts for smoother upgrades.\n- Removed legacy `clawbrain.py` in favor of a modular and more maintainable structure.\n\nv0.1.6 | 2026-02-07T17:59:48.405Z | user\n\nDid not like the slug brain-v3-skill, hence moved it to more proper slug: clawbrain\n\nSince we ha a major update in clawbrain, Am updating this one last time to point this skill to clawbrain repo so that existing installations can be benefitted as well.\n\nv0.1.3 | 2026-02-02T02:31:20.924Z | auto\n\n**Changelog for brain-v3-skill v0.1.3**\n\n- Migrated documentation and references from brain-v3-skill to the new standalone Claw Brain repository.\n- Updated SKILL.md to direct users to the new Claw Brain repository and installation instructions.\n- Removed detailed usage and architecture instructions specific to brain-v3-skill from SKILL.md.\n- Added migration notes and simplified examples for getting started with Claw Brain.\n\nv0.1.2 | 2026-02-02T00:22:03.691Z | auto\n\nVersion 0.1.2\n\n- No file or documentation changes detected.\n- No user-facing or internal changes in this release.\n\nv0.1.1 | 2026-02-01T23:18:53.972Z | auto\n\nNo changes detected for version 0.1.1.\n\n- No file modifications or updates found in this release.\n- Functionality, documentation, and features remain unchanged from the previous version.\n\nv0.1.0 | 2026-02-01T17:51:57.457Z | auto\n\nInitial release of Brain v3 – comprehensive AI agent memory system:\n\n- Introduces Soul (dynamic personality traits), Bonding (relationship tracking), and semantic search capabilities\n- Supports secure, encrypted storage for sensitive agent memories\n- Includes unified handling for goals, todos, and conversation history\n- Provides extensible memory types for flexible agent use cases\n- Offers quick-start instructions, API examples, and recommended database schema\n- Empowers AI agents to evolve and personalize responses through feedback and interaction\n\nArchive index:\n\nArchive v0.1.10: 31 files, 69774 bytes\n\nFiles: __init__.py (960b), .github/workflows/publish.yml (2839b), .github/workflows/tests.yml (1769b), brain/__init__.py (413b), brain/hooks/clawbrain-startup/handler.js (7247b), brain/hooks/clawbrain-startup/HOOK.md (1927b), brain/README.md (132b), brain/scripts/brain_bridge.py (4125b), brain/scripts/migrate_agent_id.py (696b), CHANGELOG.md (7411b), clawbrain_cli.py (31210b), clawbrain.py (63123b), hooks/clawbrain-startup/handler.js (7247b), hooks/clawbrain-startup/HOOK.md (1927b), install.sh (3456b), pyproject.toml (2234b), README.md (8082b), remote-install.sh (2723b), scripts/brain_bridge.py (4125b), scripts/migrate_agent_id.py (696b), SECURITY_FIXES.md (8469b), skill.json (1989b), SKILL.md (10397b), test_encryption.py (5480b), tests/integration_test.py (15718b), tests/README.md (3778b), tests/run_integration_tests.sh (3515b), tests/run_local_tests.sh (2077b), tests/test_openclaw_container.py (13084b), tests/test_openclaw_integration.sh (9071b), _meta.json (134b)\n\nFile v0.1.10:SKILL.md\n\n---\nname: clawbrain\nversion: 0.1.10\ndescription: \"Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities with encrypted secrets support. Auto-refreshes on service restart.\"\nmetadata: {\"openclaw\":{\"emoji\":\"🧠\",\"category\":\"memory\",\"provides\":{\"slot\":\"memory\"},\"events\":[\"gateway:startup\",\"command:new\"]},\"clawdbot\":{\"emoji\":\"🧠\",\"category\":\"memory\",\"provides\":{\"slot\":\"memory\"},\"events\":[\"gateway:startup\",\"command:new\"]}}\n---\n\n# Claw Brain Skill 🧠\n\nPersonal AI Memory System with Soul, Bonding, and Learning for OpenClaw/ClawDBot.\n\n> **Auto-Refresh on Restart**: ClawBrain automatically refreshes memory when the service restarts.\n\n## Features\n\n- 🎭 **Soul/Personality** - 6 evolving traits (humor, empathy, curiosity, creativity, helpfulness, honesty)\n- 👤 **User Profile** - Learns user preferences, interests, communication style\n- 💭 **Conversation State** - Real-time mood detection and context tracking\n- 📚 **Learning Insights** - Continuously learns from interactions and corrections\n- 🧠 **get_full_context()** - Everything for personalized responses\n- 🔄 **Auto-Refresh** - Automatically refreshes memory on service restart\n- 🔐 **Encrypted Secrets** - Store API keys and credentials securely\n\n---\n\n## Quick Install\n\n### From PyPI (Recommended)\n\n```bash\n# Install with all features\npip install clawbrain[all]\n\n# Run interactive setup\nclawbrain setup\n\n# Backup your encryption key (IMPORTANT!)\nclawbrain backup-key --all\n\n# Restart your service\nsudo systemctl restart clawdbot  # or openclaw\n```\n\nThe setup command will:\n1. Detect your platform (ClawdBot or OpenClaw)\n2. Generate a secure encryption key\n3. Install the startup hook automatically\n4. Test the installation\n\n### Alternative: From Source\n\n```bash\n# Clone to your skills directory\ncd ~/.openclaw/skills  # or ~/clawd/skills or ~/.clawdbot/skills\ngit clone https://github.com/clawcolab/clawbrain.git\ncd clawbrain\npip install -e .[all]\nclawbrain setup\n```\n\n---\n\n## Configuration\n\nAfter installation, optionally configure your agent ID:\n\n```bash\n# Create systemd drop-in config\nsudo mkdir -p /etc/systemd/system/clawdbot.service.d  # or openclaw.service.d\n\nsudo tee /etc/systemd/system/clawdbot.service.d/brain.conf << EOF\n[Service]\nEnvironment=\"BRAIN_AGENT_ID=your-agent-name\"\n# Optional: PostgreSQL (for production)\n# Environment=\"BRAIN_POSTGRES_HOST=localhost\"\n# Environment=\"BRAIN_POSTGRES_PASSWORD=your-password\"\n# Optional: Redis (for caching)\n# Environment=\"BRAIN_REDIS_HOST=localhost\"\nEOF\n\nsudo systemctl daemon-reload\nsudo systemctl restart clawdbot  # or openclaw\n```\n\n### Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `BRAIN_AGENT_ID` | Unique ID for this agent's memories | `default` |\n| `BRAIN_ENCRYPTION_KEY` | Fernet key for encrypting sensitive data (auto-generated if not set) | - |\n| `BRAIN_POSTGRES_HOST` | PostgreSQL host | `localhost` |\n| `BRAIN_POSTGRES_PASSWORD` | PostgreSQL password | - |\n| `BRAIN_POSTGRES_PORT` | PostgreSQL port | `5432` |\n| `BRAIN_POSTGRES_DB` | PostgreSQL database | `brain_db` |\n| `BRAIN_POSTGRES_USER` | PostgreSQL user | `brain_user` |\n| `BRAIN_REDIS_HOST` | Redis host | `localhost` |\n| `BRAIN_REDIS_PORT` | Redis port | `6379` |\n| `BRAIN_STORAGE` | Force storage: `sqlite`, `postgresql`, `auto` | `auto` |\n\n---\n\n## How It Works\n\n### On Service Startup\n1. Hook triggers on `gateway:startup` event\n2. Detects storage backend (SQLite/PostgreSQL)\n3. Loads memories for the configured `BRAIN_AGENT_ID`\n4. Injects context into agent bootstrap\n\n### On `/new` Command\n1. Hook triggers on `command:new` event  \n2. Saves current session summary to memory\n3. Clears session state for fresh start\n\n### Storage Priority\n1. **PostgreSQL** - If available and configured\n2. **SQLite** - Fallback, zero configuration needed\n\n---\n\n## Encrypted Secrets\n\nClawBrain supports encrypting sensitive data like API keys and credentials.\n\n**Setup:**\n```bash\n# Run setup to generate encryption key\nclawbrain setup\n\n# Backup your key (IMPORTANT!)\nclawbrain backup-key --all\n```\n\n**Usage:**\n```python\n# Store encrypted secret\nbrain.remember(\n    agent_id=\"assistant\",\n    memory_type=\"secret\",  # Memory type 'secret' triggers encryption\n    content=\"sk-1234567890abcdef\",\n    key=\"openai_api_key\"\n)\n\n# Retrieve and automatically decrypt\nsecrets = brain.recall(agent_id=\"assistant\", memory_type=\"secret\")\napi_key = secrets[0].content  # Automatically decrypted\n```\n\n**Key Management CLI:**\n```bash\nclawbrain show-key          # View key info (masked)\nclawbrain show-key --full   # View full key\nclawbrain backup-key --all  # Backup with all methods\nclawbrain generate-key      # Generate new key\n```\n\n⚠️ **Important**: Backup your encryption key! Lost keys = lost encrypted data.\n\n---\n\n## CLI Commands\n\nClawBrain includes a command-line interface:\n\n| Command | Description |\n|---------|-------------|\n| `clawbrain setup` | Set up ClawBrain, generate key, install hooks |\n| `clawbrain generate-key` | Generate new encryption key |\n| `clawbrain show-key` | Display current encryption key |\n| `clawbrain backup-key` | Backup key (file, QR, clipboard) |\n| `clawbrain health` | Check health status |\n| `clawbrain info` | Show installation info |\n\n---\n\n## Hooks\n\n| Event | Action |\n|-------|--------|\n| `gateway:startup` | Initialize brain, refresh memories |\n| `command:new` | Save session to memory |\n\n---\n\n## Development Installation\n\nFor development or manual installation:\n\n```bash\n# Clone to your skills directory\ncd ~/.openclaw/skills  # or ~/clawd/skills or ~/.clawdbot/skills\ngit clone https://github.com/clawcolab/clawbrain.git\ncd clawbrain\n./install.sh\n```\n\n---\n\n## Python API\n\nFor direct Python usage (outside ClawdBot/OpenClaw):\n\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\n```\n\n#### Methods\n\n| Method | Description | Returns |\n|--------|-------------|---------|\n| `get_full_context()` | Get all context for personalized responses | dict |\n| `remember()` | Store a memory | None |\n| `recall()` | Retrieve memories | List[Memory] |\n| `learn_user_preference()` | Learn user preferences | None |\n| `get_user_profile()` | Get user profile | UserProfile |\n| `detect_user_mood()` | Detect current mood | dict |\n| `detect_user_intent()` | Detect message intent | str |\n| `generate_personality_prompt()` | Generate personality guidance | str |\n| `health_check()` | Check backend connections | dict |\n| `close()` | Close connections | None |\n\n### get_full_context()\n\n```python\ncontext = brain.get_full_context(\n    session_key=\"telegram_12345\",  # Unique session ID\n    user_id=\"username\",              # User identifier\n    agent_id=\"assistant\",          # Bot identifier\n    message=\"Hey, how's it going?\" # Current message\n)\n```\n\n**Returns:**\n```python\n{\n    \"user_profile\": {...},        # User preferences, interests\n    \"mood\": {\"mood\": \"happy\", ...},  # Current mood\n    \"intent\": \"question\",         # Detected intent\n    \"memories\": [...],            # Relevant memories\n    \"personality\": \"...\",         # Personality guidance\n    \"suggested_responses\": [...]  # Response suggestions\n}\n```\n\n### detect_user_mood()\n\n```python\nmood = brain.detect_user_mood(\"I'm so excited about this!\")\n# Returns: {\"mood\": \"happy\", \"confidence\": 0.9, \"emotions\": [\"joy\", \"anticipation\"]}\n```\n\n### detect_user_intent()\n\n```python\nintent = brain.detect_user_intent(\"How does AI work?\")\n# Returns: \"question\"\n\nintent = brain.detect_user_intent(\"Set a reminder for 3pm\")\n# Returns: \"command\"\n\nintent = brain.detect_user_intent(\"I had a great day today\")\n# Returns: \"casual\"\n```\n\n---\n\n## Example: Full Integration\n\n```python\nimport sys\nsys.path.insert(0, \"ClawBrain\")\n\nfrom clawbrain import Brain\n\nclass AssistantBot:\n    def __init__(self):\n        self.brain = Brain()\n    \n    def handle_message(self, message, chat_id):\n        # Get context\n        context = self.brain.get_full_context(\n            session_key=f\"telegram_{chat_id}\",\n            user_id=str(chat_id),\n            agent_id=\"assistant\",\n            message=message\n        )\n        \n        # Generate response using context\n        response = self.generate_response(context)\n        \n        # Learn from interaction\n        self.brain.learn_user_preference(\n            user_id=str(chat_id),\n            pref_type=\"interest\",\n            value=\"AI\"\n        )\n        \n        return response\n    \n    def generate_response(self, context):\n        # Use user preferences\n        name = context[\"user_profile\"].name or \"there\"\n        mood = context[\"mood\"][\"mood\"]\n        \n        # Personalized response\n        if mood == \"frustrated\":\n            return f\"Hey {name}, I'm here to help. Let me assist you.\"\n        else:\n            return f\"Hi {name}! How can I help you today?\"\n    \n    def shutdown(self):\n        self.brain.close()\n```\n\n---\n\n## Storage Backends\n\n### SQLite (Default - Zero Setup)\n\nNo configuration needed. Data stored in local SQLite database.\n\n```python\nbrain = Brain({\"storage_backend\": \"sqlite\"})\n```\n\n**Best for:** Development, testing, single-user deployments\n\n### PostgreSQL + Redis (Production)\n\nRequires PostgreSQL and Redis servers.\n\n```python\nbrain = Brain()  # Auto-detects\n```\n\n**Requirements:**\n- PostgreSQL 14+\n- Redis 6+\n- Python packages: `psycopg2-binary`, `redis`\n\n```bash\npip install psycopg2-binary redis\n```\n\n**Best for:** Production, multi-user, high-concurrency\n\n---\n\n## Files\n\n- `clawbrain.py` - Main Brain class with all features\n- `__init__.py` - Module exports\n- `SKILL.md` - This documentation\n- `skill.json` - ClawdHub metadata\n- `README.md` - Quick start guide\n\n---\n\n## Troubleshooting\n\n### ImportError: No module named 'clawbrain'\n\n```bash\n# Ensure ClawBrain folder is in your path\nsys.path.insert(0, \"ClawBrain\")\n```\n\n### PostgreSQL connection failed\n\n```bash\n# Check environment variables\necho $POSTGRES_HOST\necho $POSTGRES_PORT\n\n# Verify PostgreSQL is running\npg_isready -h $POSTGRES_HOST -p $POSTGRES_PORT\n```\n\n### Redis connection failed\n\n```bash\n# Check Redis is running\nredis-cli ping\n```\n\n### Using SQLite (fallback)\n\nIf PostgreSQL/Redis are unavailable, Claw Brain automatically falls back to SQLite:\n\n```python\nbrain = Brain({\"storage_backend\": \"sqlite\"})\n```\n\n---\n\n## Learn More\n\n- **Repository:** https://github.com/clawcolab/clawbrain\n- **README:** See README.md for quick start\n- **Issues:** Report bugs at GitHub Issues\n\nFile v0.1.10:brain/README.md\n\n# Brain Module\n\nThis folder exists for backward compatibility.\n\nThe main module is at the root level: `from clawbrain import Brain`\n\nFile v0.1.10:README.md\n\n# Claw Brain 🧠\n\n**Personal AI Memory System for AI Agents**\n\nA sophisticated memory and learning system that enables truly personalized AI-human communication.\n\n## Features\n\n- 🎭 **Soul/Personality** - 6 evolving traits (humor, empathy, curiosity, creativity, helpfulness, honesty)\n- 👤 **User Profile** - Learns user preferences, interests, communication style\n- 💭 **Conversation State** - Real-time mood detection and context tracking\n- 📚 **Learning Insights** - Continuously learns from interactions and corrections\n- 🧠 **get_full_context()** - Everything for personalized responses\n- 🔐 **Encrypted Secrets** - Securely store API keys and credentials\n\n## Installation\n\n### From PyPI (Recommended)\n\n```bash\n# Basic installation\npip install clawbrain\n\n# With encryption support (recommended)\npip install clawbrain[encryption]\n\n# With all optional features\npip install clawbrain[all]\n```\n\n### Post-Installation Setup\n\nAfter installation, run the setup command:\n\n```bash\n# Interactive setup (generates encryption key, installs hooks)\nclawbrain setup\n\n# Backup your encryption key (important!)\nclawbrain backup-key --all\n```\n\n### For ClawdBot / OpenClaw\n\n```bash\n# Install with all features\npip install clawbrain[all]\n\n# Run setup to install hooks\nclawbrain setup\n\n# Restart your service\nsudo systemctl restart clawdbot  # or openclaw\n```\n\nThe setup command will:\n- Generate a secure encryption key\n- Detect your platform (ClawdBot or OpenClaw)\n- Install the startup hook automatically\n- Test the installation\n\n**Configure your agent ID** (optional, add to systemd service):\n```bash\nsudo mkdir -p /etc/systemd/system/clawdbot.service.d  # or openclaw.service.d\nsudo tee /etc/systemd/system/clawdbot.service.d/brain.conf << EOF\n[Service]\nEnvironment=\"BRAIN_AGENT_ID=your-agent-name\"\nEOF\nsudo systemctl daemon-reload\nsudo systemctl restart clawdbot  # or openclaw\n```\n\n### For Python Projects\n\n```bash\npip install clawbrain[encryption]\n```\n\n## Quick Start\n\n```bash\npip install clawbrain[encryption]\n```\n\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\ncontext = brain.get_full_context(\n    session_key=\"chat_123\",\n    user_id=\"user\",\n    agent_id=\"assistant\",\n    message=\"Hey, how's it going?\"\n)\n```\n\n## Storage Options\n\n### Option 1: SQLite (Zero Setup) ✅ Recommended for development\n\n```python\nfrom clawbrain import Brain\n\n# Automatically uses SQLite\nbrain = Brain({\"storage_backend\": \"sqlite\"})\n```\n\n**Requirements:** Python 3.10+, no external dependencies\n\n**Best for:**\n- Development and testing\n- Single-user deployments\n- Quick prototyping\n\n---\n\n### Option 2: PostgreSQL + Redis (Production) 🚀\n\n```python\nfrom clawbrain import Brain\n\n# Auto-detects PostgreSQL and Redis\nbrain = Brain()\n```\n\n**Requirements:**\n- PostgreSQL 14+ (port 5432)\n- Redis 6+ (port 6379)\n- Python packages: `psycopg2-binary`, `redis`\n\n**Install dependencies:**\n```bash\npip install psycopg2-binary redis\n```\n\n**Environment variables (optional):**\n```bash\nexport POSTGRES_HOST=localhost\nexport POSTGRES_PORT=5432\nexport POSTGRES_DB=brain_db\nexport POSTGRES_USER=brain_user\nexport POSTGRES_PASSWORD=your_password\n\nexport REDIS_HOST=localhost\nexport REDIS_PORT=6379\n```\n\n**Best for:**\n- Production deployments\n- High-concurrency environments\n- Distributed AI agents\n- Multi-user platforms\n\n---\n\n### Auto-Detection Order\n\n1. PostgreSQL (if available)\n2. Redis (if available, used as cache)\n3. SQLite (fallback)\n\nYou can also force a specific backend:\n```python\nbrain = Brain({\"storage_backend\": \"postgresql\"})  # Force PostgreSQL\nbrain = Brain({\"storage_backend\": \"sqlite\"})      # Force SQLite\n```\n---\n\n## Encrypted Secrets 🔐\n\nClawBrain supports encrypting sensitive data like API keys and credentials.\n\n**Installation:**\n```bash\npip install clawbrain[encryption]\n```\n\n**Setup:**\n```bash\n# Generate encryption key (done automatically during setup)\nclawbrain setup\n\n# Backup your key (IMPORTANT!)\nclawbrain backup-key --all\n```\n\n**Usage:**\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\n\n# Store encrypted secret\nbrain.remember(\n    agent_id=\"assistant\",\n    memory_type=\"secret\",  # Memory type 'secret' triggers encryption\n    content=\"sk-1234567890abcdef\",\n    key=\"openai_api_key\"\n)\n\n# Retrieve and automatically decrypt\nsecrets = brain.recall(agent_id=\"assistant\", memory_type=\"secret\")\napi_key = secrets[0].content  # Automatically decrypted\n```\n\n**Encryption Key Management:**\n\nThe encryption key is automatically generated during `clawbrain setup`. Manage it with CLI:\n\n```bash\n# View key info (masked)\nclawbrain show-key\n\n# View full key\nclawbrain show-key --full\n\n# Backup key to file\nclawbrain backup-key --output ~/my_backup.txt\n\n# Backup with QR code (requires: pip install clawbrain[qr])\nclawbrain backup-key --qr\n\n# Copy to clipboard (requires: pip install clawbrain[clipboard])\nclawbrain backup-key --clipboard\n\n# All backup methods\nclawbrain backup-key --all\n```\n\n**Key Storage Locations:**\n- `~/.config/clawbrain/.brain_key` (default)\n- Or set via environment: `BRAIN_ENCRYPTION_KEY`\n\n⚠️ **Important**: Backup your encryption key! Lost keys = lost encrypted data.\n\n---\n\n## CLI Commands\n\nClawBrain includes a command-line interface for setup and management:\n\n```bash\n# Setup ClawBrain (generate key, install hooks)\nclawbrain setup\n\n# Generate new encryption key\nclawbrain generate-key\n\n# Show current encryption key\nclawbrain show-key --full\n\n# Backup encryption key\nclawbrain backup-key --all\n\n# Check health status\nclawbrain health\n\n# Show installation info\nclawbrain info\n```\n\n---\n\n## Optional Dependencies\n\nInstall with specific features:\n\n```bash\n# Encryption only\npip install clawbrain[encryption]\n\n# PostgreSQL support\npip install clawbrain[postgres]\n\n# Redis caching\npip install clawbrain[redis]\n\n# Semantic search\npip install clawbrain[embeddings]\n\n# QR code key backup\npip install clawbrain[qr]\n\n# All features\npip install clawbrain[all]\n```\n\n---\n\n## Development Installation\n\n### From GitHub\n\n```bash\npip install git+https://github.com/clawcolab/clawbrain.git\n```\n\n### From Local Development\n\n```bash\ncd /path/to/clawbrain\npip install -e .\n```\n\n### For ClawDBot\n\n```bash\n# Install as skill\ngit clone https://github.com/clawcolab/clawbrain.git ClawBrain\n```\n\nThen in your bot:\n```python\nimport sys\nsys.path.insert(0, \"ClawBrain\")\nfrom clawbrain import Brain\n\nbrain = Brain()\n```\n\n## API Reference\n\n### Core Class\n\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\n```\n\n**Methods:**\n\n| Method | Description |\n|--------|-------------|\n| `get_full_context()` | Get all context for personalized responses |\n| `remember()` | Store a memory |\n| `recall()` | Retrieve memories |\n| `learn_user_preference()` | Learn user preferences |\n| `get_user_profile()` | Get user profile |\n| `detect_user_mood()` | Detect current mood |\n| `detect_user_intent()` | Detect message intent |\n| `generate_personality_prompt()` | Generate personality guidance |\n| `health_check()` | Check backend connections |\n| `close()` | Close connections |\n\n### Data Classes\n\n```python\nfrom clawbrain import Memory, UserProfile\n\n# Memory\nmemory = Memory(\n    id=\"...\",\n    agent_id=\"assistant\",\n    memory_type=\"fact\",\n    key=\"job\",\n    content=\"User works at Walmart\",\n    importance=0.8\n)\n\n# User Profile\nprofile = UserProfile(\n    user_id=\"user\",\n    name=\"Alex\",\n    interests=[\"AI\", \"crypto\"],\n    communication_preferences={\"style\": \"casual\"}\n)\n```\n\n## Repository Structure\n\n```\nclawbrain/\n├── clawbrain.py      ← Main module\n├── __init__.py       ← Exports\n├── SKILL.md          ← ClawDBot skill docs\n├── skill.json        ← ClawdHub metadata\n└── README.md         ← This file\n```\n\n## For ClawDBot\n\nInstall as a skill via ClawdHub or manually:\n\n```bash\ngit clone https://github.com/clawcolab/clawbrain.git ClawBrain\n```\n\nUsage in your bot:\n```python\nimport sys\nsys.path.insert(0, \"ClawBrain\")\nfrom clawbrain import Brain\n\nbrain = Brain()\n\n# Get context for responses\ncontext = brain.get_full_context(\n    session_key=session_id,\n    user_id=user_id,\n    agent_id=agent_id,\n    message=user_message\n)\n```\n\n## License\n\nMIT\n\nFile v0.1.10:tests/README.md\n\n# ClawBrain Tests\n\nThis directory contains comprehensive integration tests for ClawBrain.\n\n## Test Files\n\n| File | Description |\n|------|-------------|\n| `run_integration_tests.sh` | Main test runner script (Docker-based) |\n| `run_local_tests.sh` | Run tests locally without Docker |\n| `integration_test.py` | Core integration tests (12 tests) |\n| `test_openclaw_container.py` | OpenClaw-specific integration test |\n| `test_openclaw_integration.sh` | Real system OpenClaw restart test |\n| `Dockerfile.test` | Docker image simulating OpenClaw |\n\n## Running Tests\n\n### Docker-based Integration Tests (Recommended)\n\nRun the full integration test suite in a Docker container that simulates an OpenClaw environment:\n\n```bash\n# Run all tests (13 tests total)\n./tests/run_integration_tests.sh\n\n# Force rebuild the container\n./tests/run_integration_tests.sh --build\n\n# Open a shell in the container for debugging\n./tests/run_integration_tests.sh --shell\n```\n\n### Local Tests\n\nRun tests directly without Docker:\n\n```bash\n# Install test dependencies\npip install clawbrain[all]\n\n# Run integration tests\npython tests/integration_test.py\n\n# Run encryption tests\npython test_encryption.py\n```\n\n### Real OpenClaw Integration Test\n\nIf you have OpenClaw/ClawdBot installed, test the full integration:\n\n```bash\n# Run the OpenClaw restart test\n./tests/test_openclaw_integration.sh\n\n# Skip the restart prompt\n./tests/test_openclaw_integration.sh --skip-restart\n```\n\n## Test Coverage\n\n### Core Integration Tests (12 tests)\n\n| Test | Description |\n|------|-------------|\n| Import | Verify ClawBrain can be imported |\n| Initialization | Test Brain class initialization with SQLite |\n| Remember/Recall | Test basic memory storage and retrieval |\n| Encryption Available | Verify cryptography library is installed |\n| Secret Encryption | Verify secrets are encrypted in database |\n| Auto Migration | Test automatic migration of unencrypted secrets |\n| CLI Available | Test CLI responds to --help |\n| Hooks Directory | Verify hooks are properly structured |\n| Brain Bridge | Verify brain_bridge.py exists |\n| Multiple Agents | Test agent isolation for memories |\n| Health Check | Test health_check() method |\n| Get Unencrypted Secrets | Test get_unencrypted_secrets() method |\n\n### OpenClaw Container Test (1 test, 6 steps)\n\n| Step | Description |\n|------|-------------|\n| Platform Detection | Detects if running in OpenClaw or ClawdBot |\n| Skill Installation | Verifies skill directory and files |\n| Hook Installation | Verifies hooks are installed and valid JS |\n| Brain Bridge | Verifies brain_bridge.py syntax |\n| CLI Test | Verifies CLI responds |\n| Brain Functionality | Tests remember/recall with encryption |\n\n## Container Environment\n\nThe Docker container simulates:\n\n- OpenClaw directory structure (`~/.openclaw/`)\n- Skills installation (`~/.openclaw/skills/clawbrain/`)\n- Hooks installation (`~/.openclaw/hooks/clawbrain-startup/`)\n- Python 3.11 with all dependencies\n- Node.js for hook testing\n\n## Adding New Tests\n\nAdd new test functions to `integration_test.py`:\n\n```python\ndef test_my_new_feature():\n    \"\"\"Test description.\"\"\"\n    from clawbrain import Brain\n    \n    # Your test code here\n    assert something == expected\n    log(\"Test passed message\")\n```\n\nThen add it to the `tests` list in `main()`:\n\n```python\ntests = [\n    # ... existing tests ...\n    (\"My New Feature\", test_my_new_feature),\n]\n```\n\n## Troubleshooting\n\n### \"Read-only file system\" errors\nThe container mounts the source as read-only. Tests use temp directories for write operations.\n\n### PostgreSQL/Redis connection errors\nThese are expected in the test container - it only has SQLite available.\n\n### Key generation messages\n`Generated new encryption key at...` is normal - each test creates a fresh Brain instance.\n\nFile v0.1.10:_meta.json\n\n{\n  \"ownerId\": \"kn7b1p9h4js9270g2vg6xabazn80a0d1\",\n  \"slug\": \"brain-v3-skill\",\n  \"version\": \"0.1.10\",\n  \"publishedAt\": 1770604546397\n}\n\nFile v0.1.10:brain/hooks/clawbrain-startup/HOOK.md\n\n---\nname: clawbrain-startup\ndescription: \"Refresh ClawBrain memory on startup and save sessions\"\nmetadata:\n  {\n    \"clawdbot\":\n      {\n        \"emoji\": \"🧠\",\n        \"events\": [\"gateway:startup\", \"command:new\"],\n        \"requires\": { \"files\": [\"scripts/brain_bridge.py\"] },\n        \"install\": [{ \"id\": \"workspace\", \"kind\": \"workspace\", \"label\": \"ClawBrain Skill Hook\" }],\n      },\n    \"openclaw\":\n      {\n        \"emoji\": \"🧠\",\n        \"events\": [\"gateway:startup\", \"command:new\"],\n        \"requires\": { \"files\": [\"scripts/brain_bridge.py\"] },\n        \"install\": [{ \"id\": \"workspace\", \"kind\": \"workspace\", \"label\": \"ClawBrain Skill Hook\" }],\n      },\n  }\n---\n\n# ClawBrain Startup Hook\n\nRefreshes the ClawBrain memory system on gateway startup and saves session context to brain on /new command.\n\n## Events\n\n- **gateway:startup** - Refresh brain memory on gateway startup  \n- **command:new** - Save session context to brain memory\n\n## How It Works\n\n1. **On Gateway Startup** (`gateway:startup`):\n   - Automatically refreshes brain memory\n   - Loads and indexes recent memories\n   - Reports memory count to logs\n\n2. **On Session Reset** (`command:new`):\n   - Saves current session summary to brain memory\n   - Creates searchable memory entry for future recall\n\n## Installation\n\n```bash\n# Copy to hooks directory\ncp -r hooks/clawbrain-startup ~/clawd/hooks/\n\n# Or install via clawdbot\nclawdbot hooks install /path/to/clawbrain/hooks/clawbrain-startup\n```\n\n## Requirements\n\n- ClawBrain skill must be installed in `~/clawd/skills/clawbrain`\n- Python 3.8+ with clawbrain module accessible\n\n## Configuration\n\nNo configuration required. The hook automatically uses the ClawBrain skill from the skills directory.\n\n## Disabling\n\n```bash\nclawdbot hooks disable clawbrain-startup\n```\n\nOr via config:\n\n```json\n{\n  \"hooks\": {\n    \"internal\": {\n      \"entries\": {\n        \"clawbrain-startup\": { \"enabled\": false }\n      }\n    }\n  }\n}\n```\n\nFile v0.1.10:CHANGELOG.md\n\n# Changelog\n\n## [3.1.0] - 2026-02-07\n\n### 🚀 PyPI Installation & CLI\n\nClawBrain is now available on PyPI! No more `curl | bash` - just pip install:\n\n```bash\npip install clawbrain[all]\nclawbrain setup\nclawbrain backup-key --all\n```\n\n### ✨ New Features\n\n#### Command-Line Interface (CLI)\n\nNew `clawbrain` CLI for setup and key management:\n\n| Command | Description |\n|---------|-------------|\n| `clawbrain setup` | Interactive setup - generates key, installs hooks |\n| `clawbrain generate-key` | Generate new encryption key |\n| `clawbrain show-key` | Display current encryption key |\n| `clawbrain backup-key` | Backup key (file, QR code, clipboard) |\n| `clawbrain migrate-secrets` | Migrate unencrypted secrets to encrypted storage |\n| `clawbrain health` | Check health status |\n| `clawbrain info` | Show installation info |\n\n#### Migration for Existing Installations\n\n**Automatic Migration:** When encryption is enabled for the first time (new key generated), existing unencrypted secrets are automatically migrated to encrypted storage. No manual intervention required.\n\n**Manual Migration:** If you prefer to control the migration process:\n\n```bash\n# Check for unencrypted secrets (dry run)\nclawbrain migrate-secrets --dry-run\n\n# Migrate all unencrypted secrets\nclawbrain migrate-secrets\n```\n\nThe `setup` command will automatically detect and notify you about unencrypted secrets.\n\n#### Secure Key Backup Options\n\nMultiple ways to backup your encryption key:\n\n```bash\n# Backup to file\nclawbrain backup-key --output ~/my_backup.txt\n\n# Display as QR code (scan with phone)\nclawbrain backup-key --qr\n\n# Copy to clipboard\nclawbrain backup-key --clipboard\n\n# All methods at once\nclawbrain backup-key --all\n```\n\n#### Optional Dependencies\n\nInstall only what you need:\n\n```bash\npip install clawbrain[encryption]  # Just encryption\npip install clawbrain[postgres]    # PostgreSQL support\npip install clawbrain[redis]       # Redis caching\npip install clawbrain[embeddings]  # Semantic search\npip install clawbrain[qr]          # QR code key backup\npip install clawbrain[all]         # Everything\n```\n\n### 📦 Package Improvements\n\n- **PyPI compliant** - Proper package metadata and classifiers\n- **Entry points** - `clawbrain` command available after install\n- **MANIFEST.in** - All necessary files included in distribution\n- **Optional dependencies** - Install only what you need\n\n### 🔒 Security Improvements\n\n- **Centralized key storage** - Keys stored in `~/.config/clawbrain/.brain_key`\n- **Automatic key generation** - Secure keys generated during setup\n- **Secure permissions** - Key files created with 0600 permissions\n- **Multiple backup methods** - File, QR code, clipboard options\n\n### 📁 New Files\n\n- `clawbrain_cli.py` - Command-line interface module\n- `MANIFEST.in` - Package manifest for distribution\n\n### 📝 Documentation Updates\n\n- Updated installation instructions for PyPI\n- Added CLI command documentation\n- Removed `curl | bash` as primary install method\n- Added key backup instructions\n\n---\n\n## [3.0.1] - 2026-02-07\n\n### 🔒 Security Fixes (CRITICAL)\n\nThis release addresses critical security vulnerabilities identified in v0.1.6:\n\n#### 1. Encrypted Secrets Support ✅\n- **Fixed**: Sensitive data (API keys, credentials) now properly encrypted\n- Implemented Fernet symmetric encryption using `cryptography` library\n- Added automatic encryption for `memory_type=\"secret\"`\n- Auto-generates secure encryption keys with restricted permissions (0600)\n- Automatic decryption when retrieving encrypted memories\n\n**Usage:**\n```python\n# Store encrypted secret\nbrain.remember(\n    agent_id=\"assistant\",\n    memory_type=\"secret\",\n    content=\"sk-1234567890abcdef\",\n    key=\"openai_api_key\"\n)\n\n# Retrieve automatically decrypts\nsecrets = brain.recall(agent_id=\"assistant\", memory_type=\"secret\")\napi_key = secrets[0].content  # Decrypted\n```\n\n#### 2. Secure Installation Method ✅\n- **Fixed**: Reduced supply chain attack risk\n- Documentation now recommends manual git clone first\n- Added security warnings to `curl | bash` installation method\n- Added interactive confirmation to remote-install.sh\n- Display commit hash and author for verification\n\n**Recommended Installation:**\n```bash\n# Secure method (recommended)\ncd ~/.openclaw/skills\ngit clone https://github.com/clawcolab/clawbrain.git\ncd clawbrain\n./install.sh\n```\n\n### 📦 New Features\n\n- **Encryption support**: New `BRAIN_ENCRYPTION_KEY` environment variable\n- **Optional dependencies**: Added cryptography as optional dependency in pyproject.toml\n- **Test suite**: Added test_encryption.py for verification\n- **Security documentation**: Added SECURITY_FIXES.md\n\n### 🔧 Configuration\n\nNew environment variable:\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `BRAIN_ENCRYPTION_KEY` | Fernet key for encryption | Auto-generated |\n\n### 📁 Files Modified\n\n- `clawbrain.py` - Added encryption methods\n- `brain/clawbrain.py` - Added encryption methods\n- `README.md` - Updated installation instructions\n- `SKILL.md` - Updated installation instructions\n- `remote-install.sh` - Added security prompts\n- `pyproject.toml` - Added optional dependencies\n- `skill.json` - Updated version and environment vars\n\n### 📁 New Files\n\n- `SECURITY_FIXES.md` - Detailed security fix documentation\n- `test_encryption.py` - Encryption functionality tests\n\n### ⚠️ Important Notes\n\n- **Backup encryption keys**: Lost keys = lost encrypted data\n- Existing unencrypted memories remain unencrypted\n- Install cryptography: `pip install cryptography`\n- For production: set custom `BRAIN_ENCRYPTION_KEY`\n\n---\n\n## [0.1.6] - 2026-02-04\n\n### 🚀 One-Command Install\n\nClawBrain is now truly plug-and-play. Install with a single command:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/clawcolab/clawbrain/main/remote-install.sh | bash\n```\n\nThen restart your service:\n```bash\nsudo systemctl restart clawdbot  # or openclaw\n```\n\n**That's it!** No configuration required. Works out of the box with SQLite.\n\n---\n\n### ✨ New Features\n\n- **Auto-refresh on startup** - Brain automatically loads memories when service restarts\n- **Session save on /new** - Saves conversation context when user starts new session\n- **Native hooks support** - Works with both ClawdBot and OpenClaw\n- **Auto-detection** - Detects platform, skills directory, and storage backend automatically\n- **PostgreSQL datetime fix** - Properly handles datetime serialization from PostgreSQL\n\n### 🔧 Configuration (Optional)\n\nAll configuration is optional. Set environment variables only if needed:\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `BRAIN_AGENT_ID` | Unique ID for memories | `default` |\n| `BRAIN_POSTGRES_HOST` | PostgreSQL host | SQLite used |\n| `BRAIN_REDIS_HOST` | Redis for caching | Disabled |\n\n### 📁 New Files\n\n- `install.sh` - Local installer script\n- `remote-install.sh` - Curl-based remote installer\n- `hooks/clawbrain-startup/` - Native hook for gateway events\n- `scripts/brain_bridge.py` - Python bridge for hook→brain communication\n- `scripts/migrate_agent_id.py` - Utility to migrate memories between agent IDs\n\n### 🐛 Bug Fixes\n\n- Fixed PostgreSQL datetime objects not serializing to JSON\n- Fixed UserProfile datetime fields from PostgreSQL\n- Fixed skills directory detection for different platform layouts\n\n---\n\n**Full Changelog**: https://github.com/clawcolab/clawbrain/compare/v0.1.5...v0.1.6\n\nFile v0.1.10:hooks/clawbrain-startup/HOOK.md\n\n---\nname: clawbrain-startup\ndescription: \"Refresh ClawBrain memory on startup and save sessions\"\nmetadata:\n  {\n    \"clawdbot\":\n      {\n        \"emoji\": \"🧠\",\n        \"events\": [\"gateway:startup\", \"command:new\"],\n        \"requires\": { \"files\": [\"scripts/brain_bridge.py\"] },\n        \"install\": [{ \"id\": \"workspace\", \"kind\": \"workspace\", \"label\": \"ClawBrain Skill Hook\" }],\n      },\n    \"openclaw\":\n      {\n        \"emoji\": \"🧠\",\n        \"events\": [\"gateway:startup\", \"command:new\"],\n        \"requires\": { \"files\": [\"scripts/brain_bridge.py\"] },\n        \"install\": [{ \"id\": \"workspace\", \"kind\": \"workspace\", \"label\": \"ClawBrain Skill Hook\" }],\n      },\n  }\n---\n\n# ClawBrain Startup Hook\n\nRefreshes the ClawBrain memory system on gateway startup and saves session context to brain on /new command.\n\n## Events\n\n- **gateway:startup** - Refresh brain memory on gateway startup  \n- **command:new** - Save session context to brain memory\n\n## How It Works\n\n1. **On Gateway Startup** (`gateway:startup`):\n   - Automatically refreshes brain memory\n   - Loads and indexes recent memories\n   - Reports memory count to logs\n\n2. **On Session Reset** (`command:new`):\n   - Saves current session summary to brain memory\n   - Creates searchable memory entry for future recall\n\n## Installation\n\n```bash\n# Copy to hooks directory\ncp -r hooks/clawbrain-startup ~/clawd/hooks/\n\n# Or install via clawdbot\nclawdbot hooks install /path/to/clawbrain/hooks/clawbrain-startup\n```\n\n## Requirements\n\n- ClawBrain skill must be installed in `~/clawd/skills/clawbrain`\n- Python 3.8+ with clawbrain module accessible\n\n## Configuration\n\nNo configuration required. The hook automatically uses the ClawBrain skill from the skills directory.\n\n## Disabling\n\n```bash\nclawdbot hooks disable clawbrain-startup\n```\n\nOr via config:\n\n```json\n{\n  \"hooks\": {\n    \"internal\": {\n      \"entries\": {\n        \"clawbrain-startup\": { \"enabled\": false }\n      }\n    }\n  }\n}\n```\n\nFile v0.1.10:SECURITY_FIXES.md\n\n# Security Fixes - Version 0.1.6 → 0.1.7\n\n## Summary\n\nThis document outlines the security improvements made to ClawBrain to address vulnerabilities identified in the security scan.\n\n## Issues Addressed\n\n### 1. ✅ Unencrypted Sensitive Data Storage (CRITICAL)\n\n**Problem:**\n- The `remember()` method consistently set `content_encrypted=False`\n- Sensitive data (API keys, credentials) stored in plaintext in the database\n- Documentation claimed encryption but implementation was missing\n\n**Solution:**\n- Implemented Fernet symmetric encryption using `cryptography` library\n- Added automatic encryption for `memory_type=\"secret\"`\n- Auto-generates and securely stores encryption keys with 0600 permissions\n- Automatic decryption when retrieving encrypted memories\n- Added encryption methods: `_setup_encryption()`, `_encrypt()`, `_decrypt()`\n\n**Files Modified:**\n- `clawbrain.py`\n- `brain/clawbrain.py`\n\n**Changes:**\n1. Added cryptography import and availability check\n2. Added `BRAIN_ENCRYPTION_KEY` configuration option\n3. Implemented encryption key management (auto-generation with secure storage)\n4. Modified `remember()` to encrypt content when `memory_type=\"secret\"`\n5. Modified `_row_to_memory()` to automatically decrypt encrypted content\n6. Updated `Memory` dataclass usage to properly set `content_encrypted` field\n\n**Usage Example:**\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\n\n# Store encrypted secret\nbrain.remember(\n    agent_id=\"assistant\",\n    memory_type=\"secret\",\n    content=\"sk-1234567890abcdef\",\n    key=\"openai_api_key\"\n)\n\n# Retrieve automatically decrypts\nsecrets = brain.recall(agent_id=\"assistant\", memory_type=\"secret\")\napi_key = secrets[0].content  # Decrypted automatically\n```\n\n### 2. ✅ Insecure Installation Method (SUPPLY CHAIN RISK)\n\n**Problem:**\n- Primary installation method was `curl | bash` from remote URL\n- No verification of code before execution\n- High supply chain attack risk\n\n**Solution:**\n- Reordered documentation to recommend secure manual installation first\n- Added security warnings to `curl | bash` method\n- Added interactive confirmation prompt to remote-install.sh\n- Display commit hash and author information for transparency\n- Updated documentation with security notices\n\n**Files Modified:**\n- `README.md`\n- `SKILL.md`\n- `remote-install.sh`\n\n**Changes:**\n1. Prioritized manual git clone in installation instructions\n2. Added ⚠️ security warnings about supply chain risks\n3. Added interactive confirmation before remote script execution\n4. Display git commit information for verification\n5. Recommend manual method for production environments\n\n**Recommended Installation:**\n```bash\n# Secure manual method (recommended)\ncd ~/.openclaw/skills\ngit clone https://github.com/clawcolab/clawbrain.git\ncd clawbrain\n./install.sh\n```\n\n### 3. ✅ Dependencies and Package Management\n\n**Problem:**\n- Encryption dependency not documented in package manifest\n- No clear indication of optional vs required dependencies\n\n**Solution:**\n- Added optional dependencies to `pyproject.toml`\n- Documented encryption requirements in README and SKILL docs\n\n**Files Modified:**\n- `pyproject.toml`\n\n**Changes:**\n```toml\n[project.optional-dependencies]\nencryption = [\"cryptography>=41.0.0\"]\nembeddings = [\"sentence-transformers>=2.0.0\"]\npostgres = [\"psycopg2-binary>=2.9.0\"]\nredis = [\"redis>=4.0.0\"]\nall = [\n    \"cryptography>=41.0.0\",\n    \"sentence-transformers>=2.0.0\",\n    \"psycopg2-binary>=2.9.0\",\n    \"redis>=4.0.0\"\n]\n```\n\n## Installation with Encryption Support\n\n```bash\n# Install with encryption support\npip install git+https://github.com/clawcolab/clawbrain.git#egg=clawbrain[encryption]\n\n# Install all optional dependencies\npip install git+https://github.com/clawcolab/clawbrain.git#egg=clawbrain[all]\n```\n\n## Encryption Key Management\n\n### Auto-generated Keys\n- Keys are automatically generated if `BRAIN_ENCRYPTION_KEY` is not set\n- Stored at `.brain_key` (SQLite) or `~/.config/clawbrain/.brain_key`\n- File permissions automatically set to 0600 (owner read/write only)\n\n### Custom Keys\n```bash\n# Generate a key\npython -c \"from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())\"\n\n# Set as environment variable\nexport BRAIN_ENCRYPTION_KEY=\"your-generated-key-here\"\n```\n\n### Important Notes\n- **Backup your encryption key!** Lost keys = lost encrypted data\n- Encryption keys are specific to the installation\n- Moving the database requires moving the encryption key\n- Key rotation is not currently supported\n\n## Backward Compatibility\n\n- Existing unencrypted memories remain unencrypted\n- New secrets automatically use encryption\n- No breaking changes to existing API\n- Graceful degradation if cryptography library not installed\n\n## Security Best Practices\n\n1. **Always install cryptography library for production use:**\n   ```bash\n   pip install cryptography\n   ```\n\n2. **Set a custom encryption key for production:**\n   ```bash\n   export BRAIN_ENCRYPTION_KEY=\"your-secure-key\"\n   ```\n\n3. **Use manual installation for production environments**\n\n4. **Backup encryption keys separately from database**\n\n5. **Use PostgreSQL for production (better security features)**\n\n6. **Restrict file permissions on database and key files**\n\n## Testing\n\nTo verify encryption is working:\n\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\n\n# Store a secret\nbrain.remember(\n    agent_id=\"test\",\n    memory_type=\"secret\",\n    content=\"test-secret-value\",\n    key=\"test_key\"\n)\n\n# Verify it's encrypted in the database\n# (content should be base64-encoded ciphertext)\n\n# Retrieve and verify decryption works\nsecrets = brain.recall(agent_id=\"test\", memory_type=\"secret\")\nassert secrets[0].content == \"test-secret-value\"\nassert secrets[0].content_encrypted == True\nprint(\"✅ Encryption working correctly\")\n```\n\n## Migration Guide\n\nFor existing installations with unencrypted secrets:\n\n### Automatic Migration on Startup (Default)\n\nWhen ClawBrain initializes and generates a **new** encryption key (first-time encryption setup), it automatically:\n\n1. Detects any existing unencrypted secrets in the database\n2. Encrypts them using the newly generated key\n3. Updates the records with encrypted content\n\nThis happens transparently during `Brain()` initialization - no manual intervention required for agent-driven installations.\n\n```python\n# Automatic migration happens here when key is first generated\nbrain = Brain()  \n# Logs: \"Found N unencrypted secrets - auto-migrating...\"\n# Logs: \"Auto-migration complete: N secrets encrypted\"\n```\n\n### CLI Migration (Manual Control)\n\nUse the CLI command to check or migrate unencrypted secrets:\n\n```bash\n# Check what would be migrated (dry run)\nclawbrain migrate-secrets --dry-run\n\n# Migrate all unencrypted secrets\nclawbrain migrate-secrets\n```\n\nThe `clawbrain setup` command will also detect and notify you about unencrypted secrets.\n\n### Programmatic Migration\n\nIf you need to migrate programmatically:\n\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\n\n# Check for unencrypted secrets\nunencrypted = brain.get_unencrypted_secrets()\nprint(f\"Found {len(unencrypted)} unencrypted secrets\")\n\n# Migrate them (dry_run=False to actually migrate)\nresult = brain.migrate_secrets(dry_run=False)\nprint(f\"Migrated: {result['migrated']}, Failed: {result['failed']}\")\n```\n\n### Manual Migration (Legacy)\n\nIf you need manual control:\n\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\n\n# 1. Retrieve old unencrypted secret\nold_secrets = brain.recall(agent_id=\"assistant\", memory_type=\"api_key\")\n\n# 2. Re-store with encryption\nfor secret in old_secrets:\n    brain.remember(\n        agent_id=\"assistant\",\n        memory_type=\"secret\",  # Changed to \"secret\"\n        content=secret.content,\n        key=secret.key\n    )\n\n# 3. Delete old unencrypted version (optional)\n# Implement deletion if needed\n```\n\n## Version History\n\n- **v0.1.6**: Original version with security vulnerabilities\n- **v0.1.7**: Security fixes and PyPI packaging\n  - Added encryption support for secrets\n  - Updated installation to use pip (PyPI)\n  - Added auto-migration for existing unencrypted secrets\n  - Added `clawbrain` CLI with setup, key management, and migration commands\n  - Added `get_unencrypted_secrets()` and `migrate_secrets()` API methods\n\n## References\n\n- [Cryptography Library](https://cryptography.io/)\n- [Fernet Symmetric Encryption](https://cryptography.io/en/latest/fernet/)\n- [OWASP Secure Coding Practices](https://owasp.org/www-project-secure-coding-practices-quick-reference-guide/)\n\nFile v0.1.10:skill.json\n\n{\n  \"name\": \"clawbrain\",\n  \"version\": \"3.1.0\",\n  \"description\": \"Personal AI Memory System - remembers conversations, learns preferences, provides personalized context, and securely stores encrypted secrets\",\n  \"author\": \"ClawColab\",\n  \"homepage\": \"https://github.com/clawcolab/clawbrain\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/clawcolab/clawbrain.git\"\n  },\n  \"license\": \"MIT\",\n  \"keywords\": [\"memory\", \"ai\", \"brain\", \"context\", \"personalization\", \"encryption\", \"security\"],\n  \"engines\": {\n    \"clawdbot\": \">=2024.1.0\",\n    \"openclaw\": \">=2024.1.0\"\n  },\n  \"install\": {\n    \"pip\": \"pip install clawbrain[all]\",\n    \"setup\": \"clawbrain setup\",\n    \"script\": \"./install.sh\",\n    \"remote\": \"curl -fsSL https://raw.githubusercontent.com/clawcolab/clawbrain/main/remote-install.sh | bash\"\n  },\n  \"hooks\": [\n    {\n      \"name\": \"clawbrain-startup\",\n      \"events\": [\"gateway:startup\", \"command:new\"],\n      \"description\": \"Refreshes brain memory on startup, saves session on /new\"\n    }\n  ],\n  \"environment\": {\n    \"required\": [],\n    \"optional\": [\n      {\n        \"name\": \"BRAIN_AGENT_ID\",\n        \"description\": \"Unique identifier for this agent's memories\",\n        \"default\": \"default\"\n      },\n      {\n        \"name\": \"BRAIN_ENCRYPTION_KEY\",\n        \"description\": \"Fernet encryption key for securing sensitive data (auto-generated if not set)\"\n      },\n      {\n        \"name\": \"BRAIN_POSTGRES_HOST\",\n        \"description\": \"PostgreSQL host for production storage\"\n      },\n      {\n        \"name\": \"BRAIN_POSTGRES_PASSWORD\",\n        \"description\": \"PostgreSQL password\"\n      },\n      {\n        \"name\": \"BRAIN_REDIS_HOST\",\n        \"description\": \"Redis host for caching\"\n      }\n    ]\n  },\n  \"dependencies\": {\n    \"python\": \">=3.10\",\n    \"pip\": {\n      \"optional\": [\"psycopg2-binary\", \"redis\", \"cryptography\", \"sentence-transformers\"]\n    }\n  },\n  \"metadata\": {\n    \"clawdbot\": {\n      \"emoji\": \"🧠\"\n    },\n    \"openclaw\": {\n      \"emoji\": \"🧠\"\n    }\n  }\n}\n\nFile v0.1.10:.github/workflows/publish.yml\n\nname: Publish to PyPI\n\non:\n  release:\n    types: [published]\n  workflow_dispatch:\n    inputs:\n      test_pypi:\n        description: 'Publish to Test PyPI instead'\n        required: false\n        default: false\n        type: boolean\n\njobs:\n  build:\n    name: Build distribution\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      \n      - name: Set up Python\n        uses: actions/setup-python@v5\n        with:\n          python-version: '3.11'\n      \n      - name: Install build dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install build twine\n      \n      - name: Build package\n        run: python -m build\n      \n      - name: Check package\n        run: twine check dist/*\n      \n      - name: Upload artifacts\n        uses: actions/upload-artifact@v4\n        with:\n          name: dist\n          path: dist/\n\n  test:\n    name: Test package\n    needs: build\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      \n      - name: Set up Python\n        uses: actions/setup-python@v5\n        with:\n          python-version: '3.11'\n      \n      - name: Download artifacts\n        uses: actions/download-artifact@v4\n        with:\n          name: dist\n          path: dist/\n      \n      - name: Install package from wheel\n        run: |\n          pip install dist/*.whl\n          pip install cryptography  # For encryption tests\n      \n      - name: Test import\n        run: |\n          python -c \"from clawbrain import Brain, Memory; print('Import OK')\"\n          python -c \"from clawbrain_cli import main; print('CLI OK')\"\n      \n      - name: Test CLI\n        run: clawbrain --help\n\n  publish-test-pypi:\n    name: Publish to Test PyPI\n    needs: [build, test]\n    runs-on: ubuntu-latest\n    if: github.event_name == 'workflow_dispatch' && inputs.test_pypi\n    environment:\n      name: test-pypi\n      url: https://test.pypi.org/project/clawbrain/\n    permissions:\n      id-token: write\n    steps:\n      - name: Download artifacts\n        uses: actions/download-artifact@v4\n        with:\n          name: dist\n          path: dist/\n      \n      - name: Publish to Test PyPI\n        uses: pypa/gh-action-pypi-publish@release/v1\n        with:\n          repository-url: https://test.pypi.org/legacy/\n\n  publish-pypi:\n    name: Publish to PyPI\n    needs: [build, test]\n    runs-on: ubuntu-latest\n    if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.test_pypi)\n    environment:\n      name: pypi\n      url: https://pypi.org/project/clawbrain/\n    permissions:\n      id-token: write\n    steps:\n      - name: Download artifacts\n        uses: actions/download-artifact@v4\n        with:\n          name: dist\n          path: dist/\n      \n      - name: Publish to PyPI\n        uses: pypa/gh-action-pypi-publish@release/v1\n\nFile v0.1.10:.github/workflows/tests.yml\n\nname: Tests\n\non:\n  push:\n    branches: [main, develop]\n  pull_request:\n    branches: [main]\n\njobs:\n  test:\n    name: Test Python ${{ matrix.python-version }}\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python-version: ['3.10', '3.11', '3.12']\n    \n    steps:\n      - uses: actions/checkout@v4\n      \n      - name: Set up Python ${{ matrix.python-version }}\n        uses: actions/setup-python@v5\n        with:\n          python-version: ${{ matrix.python-version }}\n      \n      - name: Install dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install .[all]\n      \n      - name: Run integration tests\n        run: python tests/integration_test.py\n      \n      - name: Test CLI\n        run: |\n          clawbrain --help\n          clawbrain info\n\n  lint:\n    name: Lint\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      \n      - name: Set up Python\n        uses: actions/setup-python@v5\n        with:\n          python-version: '3.11'\n      \n      - name: Install dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install ruff\n      \n      - name: Run ruff\n        run: ruff check .\n        continue-on-error: true  # Don't fail on lint warnings initially\n\n  build:\n    name: Build Package\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      \n      - name: Set up Python\n        uses: actions/setup-python@v5\n        with:\n          python-version: '3.11'\n      \n      - name: Install build tools\n        run: |\n          python -m pip install --upgrade pip\n          pip install build twine\n      \n      - name: Build package\n        run: python -m build\n      \n      - name: Check package\n        run: twine check dist/*\n\nArchive v0.1.6: 17 files, 37118 bytes\n\nFiles: __init__.py (971b), brain/__init__.py (497b), brain/clawbrain.py (45380b), brain/README.md (132b), CHANGELOG.md (1831b), clawbrain.py (53000b), hooks/clawbrain-startup/handler.js (4237b), hooks/clawbrain-startup/HOOK.md (1927b), install.sh (3456b), pyproject.toml (475b), README.md (5550b), remote-install.sh (1769b), scripts/brain_bridge.py (4125b), scripts/migrate_agent_id.py (696b), skill.json (1695b), SKILL.md (8443b), _meta.json (133b)\n\nFile v0.1.6:SKILL.md\n\n---\nname: clawbrain\nversion: 3.0.0\ndescription: \"Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities. Auto-refreshes on service restart.\"\nmetadata: {\"openclaw\":{\"emoji\":\"🧠\",\"category\":\"memory\",\"provides\":{\"slot\":\"memory\"},\"events\":[\"gateway:startup\",\"command:new\"]},\"clawdbot\":{\"emoji\":\"🧠\",\"category\":\"memory\",\"provides\":{\"slot\":\"memory\"},\"events\":[\"gateway:startup\",\"command:new\"]}}\n---\n\n# Claw Brain Skill 🧠\n\nPersonal AI Memory System with Soul, Bonding, and Learning for OpenClaw/ClawDBot.\n\n> **Auto-Refresh on Restart**: ClawBrain automatically refreshes memory when the service restarts.\n\n## Features\n\n- 🎭 **Soul/Personality** - 6 evolving traits (humor, empathy, curiosity, creativity, helpfulness, honesty)\n- 👤 **User Profile** - Learns user preferences, interests, communication style\n- 💭 **Conversation State** - Real-time mood detection and context tracking\n- 📚 **Learning Insights** - Continuously learns from interactions and corrections\n- 🧠 **get_full_context()** - Everything for personalized responses\n- 🔄 **Auto-Refresh** - Automatically refreshes memory on service restart\n- 🔐 **Encrypted Secrets** - Store API keys and credentials securely\n\n---\n\n## Quick Install\n\n**One-liner (recommended):**\n```bash\ncurl -fsSL https://raw.githubusercontent.com/clawcolab/clawbrain/main/remote-install.sh | bash\n```\n\nThis will:\n1. Detect your platform (ClawdBot or OpenClaw)\n2. Clone to the correct skills directory\n3. Install the startup hook automatically\n4. Check Python dependencies\n\n---\n\n## Configuration\n\nAfter installation, configure your agent ID:\n\n```bash\n# Create systemd drop-in config\nsudo mkdir -p /etc/systemd/system/clawdbot.service.d  # or openclaw.service.d\n\nsudo tee /etc/systemd/system/clawdbot.service.d/brain.conf << EOF\n[Service]\nEnvironment=\"BRAIN_AGENT_ID=your-agent-name\"\n# Optional: PostgreSQL (for production)\n# Environment=\"BRAIN_POSTGRES_HOST=localhost\"\n# Environment=\"BRAIN_POSTGRES_PASSWORD=your-password\"\n# Optional: Redis (for caching)\n# Environment=\"BRAIN_REDIS_HOST=localhost\"\nEOF\n\nsudo systemctl daemon-reload\nsudo systemctl restart clawdbot  # or openclaw\n```\n\n### Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `BRAIN_AGENT_ID` | Unique ID for this agent's memories | `default` |\n| `BRAIN_POSTGRES_HOST` | PostgreSQL host | `localhost` |\n| `BRAIN_POSTGRES_PASSWORD` | PostgreSQL password | - |\n| `BRAIN_POSTGRES_PORT` | PostgreSQL port | `5432` |\n| `BRAIN_POSTGRES_DB` | PostgreSQL database | `brain_db` |\n| `BRAIN_POSTGRES_USER` | PostgreSQL user | `brain_user` |\n| `BRAIN_REDIS_HOST` | Redis host | `localhost` |\n| `BRAIN_REDIS_PORT` | Redis port | `6379` |\n| `BRAIN_STORAGE` | Force storage: `sqlite`, `postgresql`, `auto` | `auto` |\n\n---\n\n## How It Works\n\n### On Service Startup\n1. Hook triggers on `gateway:startup` event\n2. Detects storage backend (SQLite/PostgreSQL)\n3. Loads memories for the configured `BRAIN_AGENT_ID`\n4. Injects context into agent bootstrap\n\n### On `/new` Command\n1. Hook triggers on `command:new` event  \n2. Saves current session summary to memory\n3. Clears session state for fresh start\n\n### Storage Priority\n1. **PostgreSQL** - If available and configured\n2. **SQLite** - Fallback, zero configuration needed\n\n---\n\n## Hooks\n\n| Event | Action |\n|-------|--------|\n| `gateway:startup` | Initialize brain, refresh memories |\n| `command:new` | Save session to memory |\n\n---\n\n## Manual Installation\n\nIf you prefer manual installation:\n\n```bash\n# Clone to your skills directory\ncd ~/.openclaw/skills  # or ~/clawd/skills or ~/.clawdbot/skills\ngit clone https://github.com/clawcolab/clawbrain.git\ncd clawbrain\n./install.sh\n```\n\n---\n\n## Python API\n\nFor direct Python usage (outside ClawdBot/OpenClaw):\n\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\n```\n\n#### Methods\n\n| Method | Description | Returns |\n|--------|-------------|---------|\n| `get_full_context()` | Get all context for personalized responses | dict |\n| `remember()` | Store a memory | None |\n| `recall()` | Retrieve memories | List[Memory] |\n| `learn_user_preference()` | Learn user preferences | None |\n| `get_user_profile()` | Get user profile | UserProfile |\n| `detect_user_mood()` | Detect current mood | dict |\n| `detect_user_intent()` | Detect message intent | str |\n| `generate_personality_prompt()` | Generate personality guidance | str |\n| `health_check()` | Check backend connections | dict |\n| `close()` | Close connections | None |\n\n### get_full_context()\n\n```python\ncontext = brain.get_full_context(\n    session_key=\"telegram_12345\",  # Unique session ID\n    user_id=\"username\",              # User identifier\n    agent_id=\"assistant\",          # Bot identifier\n    message=\"Hey, how's it going?\" # Current message\n)\n```\n\n**Returns:**\n```python\n{\n    \"user_profile\": {...},        # User preferences, interests\n    \"mood\": {\"mood\": \"happy\", ...},  # Current mood\n    \"intent\": \"question\",         # Detected intent\n    \"memories\": [...],            # Relevant memories\n    \"personality\": \"...\",         # Personality guidance\n    \"suggested_responses\": [...]  # Response suggestions\n}\n```\n\n### detect_user_mood()\n\n```python\nmood = brain.detect_user_mood(\"I'm so excited about this!\")\n# Returns: {\"mood\": \"happy\", \"confidence\": 0.9, \"emotions\": [\"joy\", \"anticipation\"]}\n```\n\n### detect_user_intent()\n\n```python\nintent = brain.detect_user_intent(\"How does AI work?\")\n# Returns: \"question\"\n\nintent = brain.detect_user_intent(\"Set a reminder for 3pm\")\n# Returns: \"command\"\n\nintent = brain.detect_user_intent(\"I had a great day today\")\n# Returns: \"casual\"\n```\n\n---\n\n## Example: Full Integration\n\n```python\nimport sys\nsys.path.insert(0, \"ClawBrain\")\n\nfrom clawbrain import Brain\n\nclass AssistantBot:\n    def __init__(self):\n        self.brain = Brain()\n    \n    def handle_message(self, message, chat_id):\n        # Get context\n        context = self.brain.get_full_context(\n            session_key=f\"telegram_{chat_id}\",\n            user_id=str(chat_id),\n            agent_id=\"assistant\",\n            message=message\n        )\n        \n        # Generate response using context\n        response = self.generate_response(context)\n        \n        # Learn from interaction\n        self.brain.learn_user_preference(\n            user_id=str(chat_id),\n            pref_type=\"interest\",\n            value=\"AI\"\n        )\n        \n        return response\n    \n    def generate_response(self, context):\n        # Use user preferences\n        name = context[\"user_profile\"].name or \"there\"\n        mood = context[\"mood\"][\"mood\"]\n        \n        # Personalized response\n        if mood == \"frustrated\":\n            return f\"Hey {name}, I'm here to help. Let me assist you.\"\n        else:\n            return f\"Hi {name}! How can I help you today?\"\n    \n    def shutdown(self):\n        self.brain.close()\n```\n\n---\n\n## Storage Backends\n\n### SQLite (Default - Zero Setup)\n\nNo configuration needed. Data stored in local SQLite database.\n\n```python\nbrain = Brain({\"storage_backend\": \"sqlite\"})\n```\n\n**Best for:** Development, testing, single-user deployments\n\n### PostgreSQL + Redis (Production)\n\nRequires PostgreSQL and Redis servers.\n\n```python\nbrain = Brain()  # Auto-detects\n```\n\n**Requirements:**\n- PostgreSQL 14+\n- Redis 6+\n- Python packages: `psycopg2-binary`, `redis`\n\n```bash\npip install psycopg2-binary redis\n```\n\n**Best for:** Production, multi-user, high-concurrency\n\n---\n\n## Files\n\n- `clawbrain.py` - Main Brain class with all features\n- `__init__.py` - Module exports\n- `SKILL.md` - This documentation\n- `skill.json` - ClawdHub metadata\n- `README.md` - Quick start guide\n\n---\n\n## Troubleshooting\n\n### ImportError: No module named 'clawbrain'\n\n```bash\n# Ensure ClawBrain folder is in your path\nsys.path.insert(0, \"ClawBrain\")\n```\n\n### PostgreSQL connection failed\n\n```bash\n# Check environment variables\necho $POSTGRES_HOST\necho $POSTGRES_PORT\n\n# Verify PostgreSQL is running\npg_isready -h $POSTGRES_HOST -p $POSTGRES_PORT\n```\n\n### Redis connection failed\n\n```bash\n# Check Redis is running\nredis-cli ping\n```\n\n### Using SQLite (fallback)\n\nIf PostgreSQL/Redis are unavailable, Claw Brain automatically falls back to SQLite:\n\n```python\nbrain = Brain({\"storage_backend\": \"sqlite\"})\n```\n\n---\n\n## Learn More\n\n- **Repository:** https://github.com/clawcolab/clawbrain\n- **README:** See README.md for quick start\n- **Issues:** Report bugs at GitHub Issues\n\nFile v0.1.6:brain/README.md\n\n# Brain Module\n\nThis folder exists for backward compatibility.\n\nThe main module is at the root level: `from clawbrain import Brain`\n\nFile v0.1.6:README.md\n\n# Claw Brain 🧠\n\n**Personal AI Memory System for AI Agents**\n\nA sophisticated memory and learning system that enables truly personalized AI-human communication.\n\n## Features\n\n- 🎭 **Soul/Personality** - 6 evolving traits (humor, empathy, curiosity, creativity, helpfulness, honesty)\n- 👤 **User Profile** - Learns user preferences, interests, communication style\n- 💭 **Conversation State** - Real-time mood detection and context tracking\n- 📚 **Learning Insights** - Continuously learns from interactions and corrections\n- 🧠 **get_full_context()** - Everything for personalized responses\n\n## Installation\n\n### For ClawdBot / OpenClaw (Recommended)\n\n**One-liner install:**\n```bash\ncurl -fsSL https://raw.githubusercontent.com/clawcolab/clawbrain/main/remote-install.sh | bash\n```\n\n**Or step-by-step:**\n```bash\n# Clone to your skills directory\ncd ~/.openclaw/skills  # or ~/clawd/skills or ~/.clawdbot/skills\ngit clone https://github.com/clawcolab/clawbrain.git\n\n# Run the install script\ncd clawbrain\n./install.sh\n```\n\nThe install script will:\n- Detect your platform (ClawdBot or OpenClaw)\n- Install the startup hook automatically\n- Check Python dependencies\n- Show you how to configure environment variables\n\n**Configure your agent ID** (add to systemd service):\n```bash\nsudo mkdir -p /etc/systemd/system/clawdbot.service.d  # or openclaw.service.d\nsudo tee /etc/systemd/system/clawdbot.service.d/brain.conf << EOF\n[Service]\nEnvironment=\"BRAIN_AGENT_ID=your-agent-name\"\nEOF\nsudo systemctl daemon-reload\nsudo systemctl restart clawdbot  # or openclaw\n```\n\n### For Python Projects\n\n```bash\npip install git+https://github.com/clawcolab/clawbrain.git\n```\n\n## Quick Start\n\n```bash\npip install git+https://github.com/clawcolab/clawbrain.git\n```\n\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\ncontext = brain.get_full_context(\n    session_key=\"chat_123\",\n    user_id=\"user\",\n    agent_id=\"assistant\",\n    message=\"Hey, how's it going?\"\n)\n```\n\n## Storage Options\n\n### Option 1: SQLite (Zero Setup) ✅ Recommended for development\n\n```python\nfrom clawbrain import Brain\n\n# Automatically uses SQLite\nbrain = Brain({\"storage_backend\": \"sqlite\"})\n```\n\n**Requirements:** Python 3.10+, no external dependencies\n\n**Best for:**\n- Development and testing\n- Single-user deployments\n- Quick prototyping\n\n---\n\n### Option 2: PostgreSQL + Redis (Production) 🚀\n\n```python\nfrom clawbrain import Brain\n\n# Auto-detects PostgreSQL and Redis\nbrain = Brain()\n```\n\n**Requirements:**\n- PostgreSQL 14+ (port 5432)\n- Redis 6+ (port 6379)\n- Python packages: `psycopg2-binary`, `redis`\n\n**Install dependencies:**\n```bash\npip install psycopg2-binary redis\n```\n\n**Environment variables (optional):**\n```bash\nexport POSTGRES_HOST=localhost\nexport POSTGRES_PORT=5432\nexport POSTGRES_DB=brain_db\nexport POSTGRES_USER=brain_user\nexport POSTGRES_PASSWORD=your_password\n\nexport REDIS_HOST=localhost\nexport REDIS_PORT=6379\n```\n\n**Best for:**\n- Production deployments\n- High-concurrency environments\n- Distributed AI agents\n- Multi-user platforms\n\n---\n\n### Auto-Detection Order\n\n1. PostgreSQL (if available)\n2. Redis (if available, used as cache)\n3. SQLite (fallback)\n\nYou can also force a specific backend:\n```python\nbrain = Brain({\"storage_backend\": \"postgresql\"})  # Force PostgreSQL\nbrain = Brain({\"storage_backend\": \"sqlite\"})      # Force SQLite\n```\n\n## Installation Methods\n\n### From GitHub (Recommended)\n\n```bash\npip install git+https://github.com/clawcolab/clawbrain.git\n```\n\n### From Local Development\n\n```bash\ncd /root/clawd/brain/public_package\npip install -e .\n```\n\n### For ClawDBot\n\n```bash\n# Install as skill\ngit clone https://github.com/clawcolab/clawbrain.git ClawBrain\n```\n\nThen in your bot:\n```python\nimport sys\nsys.path.insert(0, \"ClawBrain\")\nfrom clawbrain import Brain\n\nbrain = Brain()\n```\n\n## API Reference\n\n### Core Class\n\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\n```\n\n**Methods:**\n\n| Method | Description |\n|--------|-------------|\n| `get_full_context()` | Get all context for personalized responses |\n| `remember()` | Store a memory |\n| `recall()` | Retrieve memories |\n| `learn_user_preference()` | Learn user preferences |\n| `get_user_profile()` | Get user profile |\n| `detect_user_mood()` | Detect current mood |\n| `detect_user_intent()` | Detect message intent |\n| `generate_personality_prompt()` | Generate personality guidance |\n| `health_check()` | Check backend connections |\n| `close()` | Close connections |\n\n### Data Classes\n\n```python\nfrom clawbrain import Memory, UserProfile\n\n# Memory\nmemory = Memory(\n    id=\"...\",\n    agent_id=\"assistant\",\n    memory_type=\"fact\",\n    key=\"job\",\n    content=\"User works at Walmart\",\n    importance=0.8\n)\n\n# User Profile\nprofile = UserProfile(\n    user_id=\"user\",\n    name=\"Alex\",\n    interests=[\"AI\", \"crypto\"],\n    communication_preferences={\"style\": \"casual\"}\n)\n```\n\n## Repository Structure\n\n```\nclawbrain/\n├── clawbrain.py      ← Main module\n├── __init__.py       ← Exports\n├── SKILL.md          ← ClawDBot skill docs\n├── skill.json        ← ClawdHub metadata\n└── README.md         ← This file\n```\n\n## For ClawDBot\n\nInstall as a skill via ClawdHub or manually:\n\n```bash\ngit clone https://github.com/clawcolab/clawbrain.git ClawBrain\n```\n\nUsage in your bot:\n```python\nimport sys\nsys.path.insert(0, \"ClawBrain\")\nfrom clawbrain import Brain\n\nbrain = Brain()\n\n# Get context for responses\ncontext = brain.get_full_context(\n    session_key=session_id,\n    user_id=user_id,\n    agent_id=agent_id,\n    message=user_message\n)\n```\n\n## License\n\nMIT\n\nFile v0.1.6:_meta.json\n\n{\n  \"ownerId\": \"kn7b1p9h4js9270g2vg6xabazn80a0d1\",\n  \"slug\": \"brain-v3-skill\",\n  \"version\": \"0.1.6\",\n  \"publishedAt\": 1770487188405\n}\n\nFile v0.1.6:CHANGELOG.md\n\n# Changelog\n\n## [0.1.6] - 2026-02-04\n\n### 🚀 One-Command Install\n\nClawBrain is now truly plug-and-play. Install with a single command:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/clawcolab/clawbrain/main/remote-install.sh | bash\n```\n\nThen restart your service:\n```bash\nsudo systemctl restart clawdbot  # or openclaw\n```\n\n**That's it!** No configuration required. Works out of the box with SQLite.\n\n---\n\n### ✨ New Features\n\n- **Auto-refresh on startup** - Brain automatically loads memories when service restarts\n- **Session save on /new** - Saves conversation context when user starts new session\n- **Native hooks support** - Works with both ClawdBot and OpenClaw\n- **Auto-detection** - Detects platform, skills directory, and storage backend automatically\n- **PostgreSQL datetime fix** - Properly handles datetime serialization from PostgreSQL\n\n### 🔧 Configuration (Optional)\n\nAll configuration is optional. Set environment variables only if needed:\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `BRAIN_AGENT_ID` | Unique ID for memories | `default` |\n| `BRAIN_POSTGRES_HOST` | PostgreSQL host | SQLite used |\n| `BRAIN_REDIS_HOST` | Redis for caching | Disabled |\n\n### 📁 New Files\n\n- `install.sh` - Local installer script\n- `remote-install.sh` - Curl-based remote installer\n- `hooks/clawbrain-startup/` - Native hook for gateway events\n- `scripts/brain_bridge.py` - Python bridge for hook→brain communication\n- `scripts/migrate_agent_id.py` - Utility to migrate memories between agent IDs\n\n### 🐛 Bug Fixes\n\n- Fixed PostgreSQL datetime objects not serializing to JSON\n- Fixed UserProfile datetime fields from PostgreSQL\n- Fixed skills directory detection for different platform layouts\n\n---\n\n**Full Changelog**: https://github.com/clawcolab/clawbrain/compare/v0.1.5...v0.1.6\n\nFile v0.1.6:hooks/clawbrain-startup/HOOK.md\n\n---\nname: clawbrain-startup\ndescription: \"Refresh ClawBrain memory on startup and save sessions\"\nmetadata:\n  {\n    \"clawdbot\":\n      {\n        \"emoji\": \"🧠\",\n        \"events\": [\"gateway:startup\", \"command:new\"],\n        \"requires\": { \"files\": [\"scripts/brain_bridge.py\"] },\n        \"install\": [{ \"id\": \"workspace\", \"kind\": \"workspace\", \"label\": \"ClawBrain Skill Hook\" }],\n      },\n    \"openclaw\":\n      {\n        \"emoji\": \"🧠\",\n        \"events\": [\"gateway:startup\", \"command:new\"],\n        \"requires\": { \"files\": [\"scripts/brain_bridge.py\"] },\n        \"install\": [{ \"id\": \"workspace\", \"kind\": \"workspace\", \"label\": \"ClawBrain Skill Hook\" }],\n      },\n  }\n---\n\n# ClawBrain Startup Hook\n\nRefreshes the ClawBrain memory system on gateway startup and saves session context to brain on /new command.\n\n## Events\n\n- **gateway:startup** - Refresh brain memory on gateway startup  \n- **command:new** - Save session context to brain memory\n\n## How It Works\n\n1. **On Gateway Startup** (`gateway:startup`):\n   - Automatically refreshes brain memory\n   - Loads and indexes recent memories\n   - Reports memory count to logs\n\n2. **On Session Reset** (`command:new`):\n   - Saves current session summary to brain memory\n   - Creates searchable memory entry for future recall\n\n## Installation\n\n```bash\n# Copy to hooks directory\ncp -r hooks/clawbrain-startup ~/clawd/hooks/\n\n# Or install via clawdbot\nclawdbot hooks install /path/to/clawbrain/hooks/clawbrain-startup\n```\n\n## Requirements\n\n- ClawBrain skill must be installed in `~/clawd/skills/clawbrain`\n- Python 3.8+ with clawbrain module accessible\n\n## Configuration\n\nNo configuration required. The hook automatically uses the ClawBrain skill from the skills directory.\n\n## Disabling\n\n```bash\nclawdbot hooks disable clawbrain-startup\n```\n\nOr via config:\n\n```json\n{\n  \"hooks\": {\n    \"internal\": {\n      \"entries\": {\n        \"clawbrain-startup\": { \"enabled\": false }\n      }\n    }\n  }\n}\n```\n\nFile v0.1.6:skill.json\n\n{\n  \"name\": \"clawbrain\",\n  \"version\": \"3.0.0\",\n  \"description\": \"Personal AI Memory System - remembers conversations, learns preferences, and provides personalized context\",\n  \"author\": \"ClawColab\",\n  \"homepage\": \"https://github.com/clawcolab/clawbrain\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/clawcolab/clawbrain.git\"\n  },\n  \"license\": \"MIT\",\n  \"keywords\": [\"memory\", \"ai\", \"brain\", \"context\", \"personalization\"],\n  \"engines\": {\n    \"clawdbot\": \">=2024.1.0\",\n    \"openclaw\": \">=2024.1.0\"\n  },\n  \"install\": {\n    \"script\": \"./install.sh\",\n    \"remote\": \"curl -fsSL https://raw.githubusercontent.com/clawcolab/clawbrain/main/remote-install.sh | bash\"\n  },\n  \"hooks\": [\n    {\n      \"name\": \"clawbrain-startup\",\n      \"events\": [\"gateway:startup\", \"command:new\"],\n      \"description\": \"Refreshes brain memory on startup, saves session on /new\"\n    }\n  ],\n  \"environment\": {\n    \"required\": [],\n    \"optional\": [\n      {\n        \"name\": \"BRAIN_AGENT_ID\",\n        \"description\": \"Unique identifier for this agent's memories\",\n        \"default\": \"default\"\n      },\n      {\n        \"name\": \"BRAIN_POSTGRES_HOST\",\n        \"description\": \"PostgreSQL host for production storage\"\n      },\n      {\n        \"name\": \"BRAIN_POSTGRES_PASSWORD\",\n        \"description\": \"PostgreSQL password\"\n      },\n      {\n        \"name\": \"BRAIN_REDIS_HOST\",\n        \"description\": \"Redis host for caching\"\n      }\n    ]\n  },\n  \"dependencies\": {\n    \"python\": \">=3.10\",\n    \"pip\": {\n      \"optional\": [\"psycopg2-binary\", \"redis\", \"cryptography\", \"sentence-transformers\"]\n    }\n  },\n  \"metadata\": {\n    \"clawdbot\": {\n      \"emoji\": \"🧠\"\n    },\n    \"openclaw\": {\n      \"emoji\": \"🧠\"\n    }\n  }\n}\n\nFile v0.1.6:pyproject.toml\n\n[build-system]\nrequires = [\"setuptools>=61.0\", \"wheel\"]\nbuild-backend = \"setuptools.build_meta\"\n\n[project]\nname = \"clawbrain\"\nversion = \"3.0.0\"\ndescription = \"ClawBrain - Personal AI Memory System for AI Agents\"\nreadme = \"README.md\"\nlicense = {text = \"MIT\"}\nrequires-python = \">=3.10\"\n\n[project.urls]\nHomepage = \"https://github.com/clawcolab/clawbrain\"\nRepository = \"https://github.com/clawcolab/clawbrain\"\n\n[tool.setuptools.packages.find]\nwhere = [\".\"]\ninclude = [\"brain*\"]","readmeExcerpt":"Skill: Clawbrain Owner: clawcolab Summary: Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities with encrypted secrets support. Auto-refreshes on service restart. Tags: latest:0.1.10 Version history: v0.1.10 | 2026-02-09T02:35:46.397Z | user ClawBrain 0.1.7 introduces major improvements, CLI tools, encryption, and testing: - Added encryption su","codeSnippets":[],"executableExamples":[{"language":"bash","snippet":"# Install with all features\npip install clawbrain[all]\n\n# Run interactive setup\nclawbrain setup\n\n# Backup your encryption key (IMPORTANT!)\nclawbrain backup-key --all\n\n# Restart your service\nsudo systemctl restart clawdbot  # or openclaw"},{"language":"bash","snippet":"# Clone to your skills directory\ncd ~/.openclaw/skills  # or ~/clawd/skills or ~/.clawdbot/skills\ngit clone https://github.com/clawcolab/clawbrain.git\ncd clawbrain\npip install -e .[all]\nclawbrain setup"},{"language":"bash","snippet":"# Create systemd drop-in config\nsudo mkdir -p /etc/systemd/system/clawdbot.service.d  # or openclaw.service.d\n\nsudo tee /etc/systemd/system/clawdbot.service.d/brain.conf << EOF\n[Service]\nEnvironment=\"BRAIN_AGENT_ID=your-agent-name\"\n# Optional: PostgreSQL (for production)\n# Environment=\"BRAIN_POSTGRES_HOST=localhost\"\n# Environment=\"BRAIN_POSTGRES_PASSWORD=your-password\"\n# Optional: Redis (for caching)\n# Environment=\"BRAIN_REDIS_HOST=localhost\"\nEOF\n\nsudo systemctl daemon-reload\nsudo systemctl restart clawdbot  # or openclaw"},{"language":"bash","snippet":"# Run setup to generate encryption key\nclawbrain setup\n\n# Backup your key (IMPORTANT!)\nclawbrain backup-key --all"},{"language":"python","snippet":"# Store encrypted secret\nbrain.remember(\n    agent_id=\"assistant\",\n    memory_type=\"secret\",  # Memory type 'secret' triggers encryption\n    content=\"sk-1234567890abcdef\",\n    key=\"openai_api_key\"\n)\n\n# Retrieve and automatically decrypt\nsecrets = brain.recall(agent_id=\"assistant\", memory_type=\"secret\")\napi_key = secrets[0].content  # Automatically decrypted"},{"language":"bash","snippet":"clawbrain show-key          # View key info (masked)\nclawbrain show-key --full   # View full key\nclawbrain backup-key --all  # Backup with all methods\nclawbrain generate-key      # Generate new key"}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\nname: clawbrain\nversion: 0.1.10\ndescription: \"Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities with encrypted secrets support. Auto-refreshes on service restart.\"\nmetadata: {\"openclaw\":{\"emoji\":\"🧠\",\"category\":\"memory\",\"provides\":{\"slot\":\"memory\"},\"events\":[\"gateway:startup\",\"command:new\"]},\"clawdbot\":{\"emoji\":\"🧠\",\"category\":\"memory\",\"provides\":{\"slot\":\"memory\"},\"events\":[\"gateway:startup\",\"command:new\"]}}\n---\n\n# Claw Brain Skill 🧠\n\nPersonal AI Memory System with Soul, Bonding, and Learning for OpenClaw/ClawDBot.\n\n> **Auto-Refresh on Restart**: ClawBrain automatically refreshes memory when the service restarts.\n\n## Features\n\n- 🎭 **Soul/Personality** - 6 evolving traits (humor, empathy, curiosity, creativity, helpfulness, honesty)\n- 👤 **User Profile** - Learns user preferences, interests, communication style\n- 💭 **Conversation State** - Real-time mood detection and context tracking\n- 📚 **Learning Insights** - Continuously learns from interactions and corrections\n- 🧠 **get_full_context()** - Everything for personalized responses\n- 🔄 **Auto-Refresh** - Automatically refreshes memory on service restart\n- 🔐 **Encrypted Secrets** - Store API keys and credentials securely\n\n---\n\n## Quick Install\n\n### From PyPI (Recommended)\n\n```bash\n# Install with all features\npip install clawbrain[all]\n\n# Run interactive setup\nclawbrain setup\n\n# Backup your encryption key (IMPORTANT!)\nclawbrain backup-key --all\n\n# Restart your service\nsudo systemctl restart clawdbot  # or openclaw\n```\n\nThe setup command will:\n1. Detect your platform (ClawdBot or OpenClaw)\n2. Generate a secure encryption key\n3. Install the startup hook automatically\n4. Test the installation\n\n### Alternative: From Source\n\n```bash\n# Clone to your skills directory\ncd ~/.openclaw/skills  # or ~/clawd/skills or ~/.clawdbot/skills\ngit clone https://github.com/clawcolab/clawbrain.git\ncd clawbrain\npip install -e .[all]\nclawbrain setup\n```\n\n---\n\n## Configuration\n\nAfter installation, optionally configure your agent ID:\n\n```bash\n# Create systemd drop-in config\nsudo mkdir -p /etc/systemd/system/clawdbot.service.d  # or openclaw.service.d\n\nsudo tee /etc/systemd/system/clawdbot.service.d/brain.conf << EOF\n[Service]\nEnvironment=\"BRAIN_AGENT_ID=your-agent-name\"\n# Optional: PostgreSQL (for production)\n# Environment=\"BRAIN_POSTGRES_HOST=localhost\"\n# Environment=\"BRAIN_POSTGRES_PASSWORD=your-password\"\n# Optional: Redis (for caching)\n# Environment=\"BRAIN_REDIS_HOST=localhost\"\nEOF\n\nsudo systemctl daemon-reload\nsudo systemctl restart clawdbot  # or openclaw\n```\n\n### Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `BRAIN_AGENT_ID` | Unique ID for this agent's memories | `default` |\n| `BRAIN_ENCRYPTION_KEY` | Fernet key for encrypting sensitive data (auto-generated if not set) | - |\n| `BRAIN_POSTGRES_HOST` | PostgreSQL host | `localhost` |\n| `BRAIN_POSTGRES_PASSWORD` | PostgreSQL password"},{"path":"brain/README.md","content":"# Brain Module\n\nThis folder exists for backward compatibility.\n\nThe main module is at the root level: `from clawbrain import Brain`"},{"path":"README.md","content":"# Claw Brain 🧠\n\n**Personal AI Memory System for AI Agents**\n\nA sophisticated memory and learning system that enables truly personalized AI-human communication.\n\n## Features\n\n- 🎭 **Soul/Personality** - 6 evolving traits (humor, empathy, curiosity, creativity, helpfulness, honesty)\n- 👤 **User Profile** - Learns user preferences, interests, communication style\n- 💭 **Conversation State** - Real-time mood detection and context tracking\n- 📚 **Learning Insights** - Continuously learns from interactions and corrections\n- 🧠 **get_full_context()** - Everything for personalized responses\n- 🔐 **Encrypted Secrets** - Securely store API keys and credentials\n\n## Installation\n\n### From PyPI (Recommended)\n\n```bash\n# Basic installation\npip install clawbrain\n\n# With encryption support (recommended)\npip install clawbrain[encryption]\n\n# With all optional features\npip install clawbrain[all]\n```\n\n### Post-Installation Setup\n\nAfter installation, run the setup command:\n\n```bash\n# Interactive setup (generates encryption key, installs hooks)\nclawbrain setup\n\n# Backup your encryption key (important!)\nclawbrain backup-key --all\n```\n\n### For ClawdBot / OpenClaw\n\n```bash\n# Install with all features\npip install clawbrain[all]\n\n# Run setup to install hooks\nclawbrain setup\n\n# Restart your service\nsudo systemctl restart clawdbot  # or openclaw\n```\n\nThe setup command will:\n- Generate a secure encryption key\n- Detect your platform (ClawdBot or OpenClaw)\n- Install the startup hook automatically\n- Test the installation\n\n**Configure your agent ID** (optional, add to systemd service):\n```bash\nsudo mkdir -p /etc/systemd/system/clawdbot.service.d  # or openclaw.service.d\nsudo tee /etc/systemd/system/clawdbot.service.d/brain.conf << EOF\n[Service]\nEnvironment=\"BRAIN_AGENT_ID=your-agent-name\"\nEOF\nsudo systemctl daemon-reload\nsudo systemctl restart clawdbot  # or openclaw\n```\n\n### For Python Projects\n\n```bash\npip install clawbrain[encryption]\n```\n\n## Quick Start\n\n```bash\npip install clawbrain[encryption]\n```\n\n```python\nfrom clawbrain import Brain\n\nbrain = Brain()\ncontext = brain.get_full_context(\n    session_key=\"chat_123\",\n    user_id=\"user\",\n    agent_id=\"assistant\",\n    message=\"Hey, how's it going?\"\n)\n```\n\n## Storage Options\n\n### Option 1: SQLite (Zero Setup) ✅ Recommended for development\n\n```python\nfrom clawbrain import Brain\n\n# Automatically uses SQLite\nbrain = Brain({\"storage_backend\": \"sqlite\"})\n```\n\n**Requirements:** Python 3.10+, no external dependencies\n\n**Best for:**\n- Development and testing\n- Single-user deployments\n- Quick prototyping\n\n---\n\n### Option 2: PostgreSQL + Redis (Production) 🚀\n\n```python\nfrom clawbrain import Brain\n\n# Auto-detects PostgreSQL and Redis\nbrain = Brain()\n```\n\n**Requirements:**\n- PostgreSQL 14+ (port 5432)\n- Redis 6+ (port 6379)\n- Python packages: `psycopg2-binary`, `redis`\n\n**Install dependencies:**\n```bash\npip install psycopg2-binary redis\n```\n\n**Environment variables (optional):**\n```bash\nexport POSTGRES_HOST=localhost\nexport POSTGRES_PORT=5432"},{"path":"tests/README.md","content":"# ClawBrain Tests\n\nThis directory contains comprehensive integration tests for ClawBrain.\n\n## Test Files\n\n| File | Description |\n|------|-------------|\n| `run_integration_tests.sh` | Main test runner script (Docker-based) |\n| `run_local_tests.sh` | Run tests locally without Docker |\n| `integration_test.py` | Core integration tests (12 tests) |\n| `test_openclaw_container.py` | OpenClaw-specific integration test |\n| `test_openclaw_integration.sh` | Real system OpenClaw restart test |\n| `Dockerfile.test` | Docker image simulating OpenClaw |\n\n## Running Tests\n\n### Docker-based Integration Tests (Recommended)\n\nRun the full integration test suite in a Docker container that simulates an OpenClaw environment:\n\n```bash\n# Run all tests (13 tests total)\n./tests/run_integration_tests.sh\n\n# Force rebuild the container\n./tests/run_integration_tests.sh --build\n\n# Open a shell in the container for debugging\n./tests/run_integration_tests.sh --shell\n```\n\n### Local Tests\n\nRun tests directly without Docker:\n\n```bash\n# Install test dependencies\npip install clawbrain[all]\n\n# Run integration tests\npython tests/integration_test.py\n\n# Run encryption tests\npython test_encryption.py\n```\n\n### Real OpenClaw Integration Test\n\nIf you have OpenClaw/ClawdBot installed, test the full integration:\n\n```bash\n# Run the OpenClaw restart test\n./tests/test_openclaw_integration.sh\n\n# Skip the restart prompt\n./tests/test_openclaw_integration.sh --skip-restart\n```\n\n## Test Coverage\n\n### Core Integration Tests (12 tests)\n\n| Test | Description |\n|------|-------------|\n| Import | Verify ClawBrain can be imported |\n| Initialization | Test Brain class initialization with SQLite |\n| Remember/Recall | Test basic memory storage and retrieval |\n| Encryption Available | Verify cryptography library is installed |\n| Secret Encryption | Verify secrets are encrypted in database |\n| Auto Migration | Test automatic migration of unencrypted secrets |\n| CLI Available | Test CLI responds to --help |\n| Hooks Directory | Verify hooks are properly structured |\n| Brain Bridge | Verify brain_bridge.py exists |\n| Multiple Agents | Test agent isolation for memories |\n| Health Check | Test health_check() method |\n| Get Unencrypted Secrets | Test get_unencrypted_secrets() method |\n\n### OpenClaw Container Test (1 test, 6 steps)\n\n| Step | Description |\n|------|-------------|\n| Platform Detection | Detects if running in OpenClaw or ClawdBot |\n| Skill Installation | Verifies skill directory and files |\n| Hook Installation | Verifies hooks are installed and valid JS |\n| Brain Bridge | Verifies brain_bridge.py syntax |\n| CLI Test | Verifies CLI responds |\n| Brain Functionality | Tests remember/recall with encryption |\n\n## Container Environment\n\nThe Docker container simulates:\n\n- OpenClaw directory structure (`~/.openclaw/`)\n- Skills installation (`~/.openclaw/skills/clawbrain/`)\n- Hooks installation (`~/.openclaw/hooks/clawbrain-startup/`)\n- Python 3.11 with all dependencies\n- Node.js for hook testing\n\n## Adding New Tests\n"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn7b1p9h4js9270g2vg6xabazn80a0d1\",\n  \"slug\": \"brain-v3-skill\",\n  \"version\": \"0.1.10\",\n  \"publishedAt\": 1770604546397\n}"}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":"Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities with encrypted secrets support. Auto-refreshes on service restart. Skill: Clawbrain Owner: clawcolab Summary: Claw Brain - Personal AI Memory System for OpenClaw/ClawDBot. Provides memory, personality, bonding, and learning capabilities with encrypted secrets support. Auto-refreshes on service restart. Tags: latest:0.1.10 Version history: v0.1.10 | 2026-02-09T02:35:46.397Z | user ClawBrain 0.1.7 introduces major improvements, CLI tools, encryption, and testing: - Added encryption su","editorialQuality":{"score":100,"threshold":65,"status":"ready","wordCount":1366,"uniquenessScore":45,"reasons":[]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-04-15T00:45:39.800Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-04-15T00:45:39.800Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-09T13:02:20.468Z","emptyReason":null},"items":[{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-10T18:48:31.762Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}