File size: 6,098 Bytes
7eb2e6e 90eaf6f 7eb2e6e 90eaf6f 7eb2e6e 90eaf6f 7eb2e6e 90eaf6f 7eb2e6e 90eaf6f 7eb2e6e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | #!/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
# 确保密码不为空,防止进入 pairing 模式
export GW_PASS="${OPENCLAW_GATEWAY_PASSWORD:-openclaw_admin}"
# 设置 main agent 的默认 gateway 凭据 (用于 cron/heartbeat 系统)
cat > /root/.openclaw/credentials/gateway-token-main.json <<CREDS_EOF
{
"token": "$GW_PASS"
}
CREDS_EOF
# 启动前执行数据恢复
python3 /usr/local/bin/sync.py restore
# 强制生成/覆盖个性化文件 (放在基础目录和工作空间,确保 Agent 能够读取)
for TARGET_DIR in "/root/.openclaw" "/root/.openclaw/workspace"; do
mkdir -p "$TARGET_DIR"
# SOUL.md - 定义 Agent 的核心人格
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
# IDENTITY.md - 定义 Agent 的外部身份
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
# USER.md - 定义用户的偏好
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
# 设置 CLI 认证 Token
export OPENCLAW_GATEWAY_TOKEN="$GW_PASS"
# 设置 OpenAI embeddings API 指向 OpenRouter
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"
# 生成 openclaw.json 配置文件
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 网关
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
|