82 lines
2.6 KiB
Bash
82 lines
2.6 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
config=/www/dk_project/openclaw/config/openclaw.json
|
|
workspace=/www/dk_project/openclaw/config/workspace-wechat-responder
|
|
agent_state=/www/dk_project/openclaw/config/agents/wechat-responder
|
|
timestamp=$(date +%Y%m%d-%H%M%S)
|
|
backup="${config}.bak.wechat-responder-${timestamp}"
|
|
success=0
|
|
|
|
rollback() {
|
|
status=$?
|
|
if [ "$success" -eq 0 ]; then
|
|
cp -a "$backup" "$config"
|
|
rm -rf "$workspace" "$agent_state"
|
|
fi
|
|
exit "$status"
|
|
}
|
|
|
|
trap rollback EXIT HUP INT TERM
|
|
|
|
test -f "$config"
|
|
test ! -e "$workspace"
|
|
test ! -e "$agent_state"
|
|
test -f /tmp/wechat-responder-AGENTS.md
|
|
test -f /tmp/wechat-responder-SOUL.md
|
|
test -f /tmp/wechat-responder-IDENTITY.md
|
|
test -f /tmp/wechat-responder-USER.md
|
|
|
|
cp -a "$config" "$backup"
|
|
timeout 45 docker exec openclaw-gateway \
|
|
node /app/dist/index.js agents add wechat-responder \
|
|
--workspace /home/node/.openclaw/workspace-wechat-responder \
|
|
--model deepseek/deepseek-flash \
|
|
--non-interactive \
|
|
--json
|
|
|
|
install -d -o 1000 -g 1000 -m 0700 "$workspace"
|
|
install -o 1000 -g 1000 -m 0644 \
|
|
/tmp/wechat-responder-AGENTS.md \
|
|
"$workspace/AGENTS.md"
|
|
install -o 1000 -g 1000 -m 0644 \
|
|
/tmp/wechat-responder-SOUL.md \
|
|
"$workspace/SOUL.md"
|
|
install -o 1000 -g 1000 -m 0644 \
|
|
/tmp/wechat-responder-IDENTITY.md \
|
|
"$workspace/IDENTITY.md"
|
|
install -o 1000 -g 1000 -m 0644 \
|
|
/tmp/wechat-responder-USER.md \
|
|
"$workspace/USER.md"
|
|
rm -f "$workspace/BOOTSTRAP.md"
|
|
|
|
temporary="${config}.wechat-responder.tmp"
|
|
jq '
|
|
.agents.entries["wechat-responder"].name = "WeChat Tool-Free Chat"
|
|
| .agents.entries["wechat-responder"].thinkingDefault = "off"
|
|
| del(.agents.entries["wechat-responder"].timeoutSeconds)
|
|
| .agents.entries["wechat-responder"].skills = []
|
|
| .agents.entries["wechat-responder"].tools = {
|
|
"profile": "minimal",
|
|
"allow": ["session_status"],
|
|
"codeMode": false
|
|
}
|
|
' "$config" > "$temporary"
|
|
chown --reference="$config" "$temporary"
|
|
chmod --reference="$config" "$temporary"
|
|
mv "$temporary" "$config"
|
|
|
|
sleep 3
|
|
test "$(jq -r '.agents.entries["wechat-responder"].tools.profile' "$config")" = minimal
|
|
test "$(jq -r '.agents.entries["wechat-responder"].tools.allow | join(",")' "$config")" = session_status
|
|
test "$(jq -r '.agents.entries["wechat-responder"].tools.codeMode' "$config")" = false
|
|
test "$(jq -r '.agents.entries["wechat-responder"].skills | length' "$config")" -eq 0
|
|
test "$(jq -r '.agents.entries["wechat-responder"] | has("timeoutSeconds")' "$config")" = false
|
|
test ! -e "$workspace/BOOTSTRAP.md"
|
|
|
|
success=1
|
|
trap - EXIT HUP INT TERM
|
|
|
|
echo "backup=$backup"
|
|
jq -c '.agents.entries["wechat-responder"]' "$config"
|