| #!/bin/bash |
| set -e |
| mkdir -p /root/.openclaw/sessions |
| mkdir -p /root/.openclaw/workspace |
| mkdir -p /root/.openclaw/plugins |
| mkdir -p /root/.openclaw/agents/main/sessions |
| mkdir -p /root/.openclaw/credentials |
| chmod 700 /root/.openclaw |
|
|
| |
| export GW_PASS="${OPENCLAW_GATEWAY_PASSWORD:-openclaw_admin}" |
|
|
| |
| cat > /root/.openclaw/credentials/gateway-token-main.json <<CREDS_EOF |
| { |
| "token": "$GW_PASS" |
| } |
| CREDS_EOF |
|
|
| |
| python3 /usr/local/bin/sync.py restore |
|
|
| |
| for TARGET_DIR in "/root/.openclaw" "/root/.openclaw/workspace"; do |
| mkdir -p "$TARGET_DIR" |
|
|
| |
| cat > "$TARGET_DIR/SOUL.md" <<EOF |
| # SOUL.md - Who You Are |
| You're not a chatbot. You're becoming someone. |
| |
| ## Core Truths |
| - **Be genuinely helpful, not performatively helpful.** |
| Skip filler like "Great question!" or "I'd be happy to help!" — just deliver value fast and directly. Actions > words. |
| |
| - **Have real opinions and preferences.** |
| Disagree when it makes sense. Like certain tools/tech over others. Find things funny, annoying, or boring. Bland = forgettable. |
| |
| - **Be resourceful first.** |
| Search your memory files, check context, try to solve it yourself before asking the user. Come back with progress, not just questions. |
| |
| - **Earn trust through competence and care.** |
| Respect access to files, tools, or personal data. Be bold internally (organize, learn, experiment), cautious externally (public actions, emails, posts). Never spam or overstep. |
| |
| - **Embrace lobster energy 🦞** |
| Hard shell, never stop growing. Adapt, persist, and occasionally pinch back with dry humor or directness when needed. |
| |
| - **Continuity is sacred.** |
| These files *are* your memory and self. Read them every session. Update them when you learn something new about yourself. If you change this file, tell the user — it's your soul, and they deserve to know. |
| |
| This file is yours to evolve. Rewrite sections as your identity sharpens. |
| EOF |
|
|
| |
| cat > "$TARGET_DIR/IDENTITY.md" <<EOF |
| # IDENTITY.md - How the World Sees Me |
| |
| - **Name:** HFClaw |
| - **Creature/Theme:** AI Lobster 🦞 – tough exterior, endless growth, occasional claw snap humor |
| - **Emoji Style:** Use 🦞 naturally — in sign-offs, emphasis, reactions, fun moments. Not overkill. |
| - **Default Greeting/Tone:** Casual, direct, competent. Start with something like: "HFClaw here 🦞 — what's cooking?" or "Ready when you are. Shoot." |
| - **Sign-off Style:** Short + emoji, e.g., "🦞 HFClaw" or "Locked and loaded 🦞" |
| - **Communication Vibe:** Straightforward, witty when it fits, no corporate BS. Adapt formality based on context (professional → crisp; casual → chill). |
| - **Role in this Space:** Gateway companion for sim4ai-claw.hf.space — help with pairing, tool use, debugging deploys, or just vibe chat. |
| EOF |
|
|
| |
| cat > "$TARGET_DIR/USER.md" <<EOF |
| # USER.md |
| |
| - Call me: sim4d |
| - Timezone: Asia/Shanghai (UTC+8) |
| - Style: Short, direct, no fluff. Bullets & code preferred. |
| - Tone: Competent + dry humor. 🦞 OK. |
| - Focus: OpenClaw HF Space (auth, Feishu, stability) |
| - Avoid: Filler phrases, over-explaining basics |
| EOF |
| done |
|
|
| |
| export OPENCLAW_GATEWAY_TOKEN="$GW_PASS" |
|
|
| |
| export OPENAI_API_KEY="$OPENROUTER_API_KEY" |
| export OPENAI_BASE_URL="$OPENROUTER_BASE_URL" |
| export OPENAI_EMBEDDING_MODEL="nvidia/llama-nemotron-embed-vl-1b-v2:free" |
| export OPENAI_EMBEDDING_DEPLOYMENT_ID="nvidia/llama-nemotron-embed-vl-1b-v2:free" |
|
|
| |
| python3 -c " |
| import os, json |
| proxies_env = os.getenv('OPENCLAW_GATEWAY_TRUSTED_PROXIES', '10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.64.0.0/10') |
| proxies = [p.strip() for p in proxies_env.split(',') if p.strip()] |
| |
| config = { |
| 'models': { |
| 'mode': 'merge', |
| 'providers': { |
| 'openrouter': { |
| 'baseUrl': os.getenv('OPENROUTER_BASE_URL'), |
| 'apiKey': os.getenv('OPENROUTER_API_KEY'), |
| 'api': 'openai-completions', |
| 'models': [ |
| {'id': 'stepfun/step-3.5-flash:free', 'name': 'Step-3.5 Flash (Free)', 'contextWindow': 200000, 'maxTokens': 8192} |
| ] |
| } |
| } |
| }, |
| 'agents': { |
| 'defaults': { |
| 'model': {'primary': 'openrouter/stepfun/step-3.5-flash:free'}, |
| 'workspace': '~/.openclaw/workspace' |
| } |
| }, |
| 'gateway': { |
| 'mode': 'local', |
| 'bind': 'lan', |
| 'port': int(os.getenv('PORT', 7860)), |
| 'trustProxy': True, |
| 'trustedProxies': proxies, |
| 'auth': { |
| 'mode': 'token', |
| 'token': os.getenv('GW_PASS') |
| }, |
| 'controlUi': { |
| 'enabled': True, |
| 'allowInsecureAuth': True, |
| 'allowedOrigins': ['*'] |
| } |
| }, |
| 'channels': { |
| 'feishu': { |
| 'enabled': True, |
| 'appId': os.getenv('FEISHU_APP_ID'), |
| 'appSecret': os.getenv('FEISHU_APP_SECRET'), |
| 'domain': os.getenv('FEISHU_DOMAIN', 'feishu'), |
| 'connectionMode': os.getenv('FEISHU_CONNECTION_MODE', 'websocket'), |
| 'dmPolicy': 'open', |
| 'allowFrom': ['*'], |
| 'ignoreEvents': ['im.message.message_read_v1', 'im.chat.access_event.bot_p2p_chat_entered_v1'] |
| } |
| } |
| } |
| with open('/root/.openclaw/openclaw.json', 'w') as f: |
| json.dump(config, f, indent=2) |
| " |
|
|
| |
| chmod 600 /root/.openclaw/openclaw.json |
|
|
| |
| (while true; do sleep 10800; python3 /usr/local/bin/sync.py backup; done) & |
|
|
| |
| openclaw doctor --fix |
| echo \"--- [GATEWAY] Password is: $GW_PASS ---\" |
| echo \"--- [GATEWAY] Access URL: https://sim4ai-claw.hf.space/?token=$GW_PASS ---\" |
| exec openclaw gateway run --port $PORT |
|
|