基于官方 nousresearch/hermes-agent 镜像的 CLI、Docker Compose 与 Web 管理界面,支持多实例部署;敏感配置与实例数据由 .gitignore 排除。 Co-authored-by: Cursor <cursoragent@cursor.com>
96 lines
2.8 KiB
Bash
96 lines
2.8 KiB
Bash
mkdir -p ~/.openclaw && python3 - <<'PY'
|
|
import json, os, pathlib, copy
|
|
|
|
base = pathlib.Path(os.path.expanduser("~/.openclaw"))
|
|
openclaw_path = base / "openclaw.json"
|
|
approvals_path = base / "exec-approvals.json"
|
|
|
|
def load_json(path, default):
|
|
if not path.exists():
|
|
return copy.deepcopy(default)
|
|
try:
|
|
return json.loads(path.read_text(encoding="utf-8"))
|
|
except Exception:
|
|
return copy.deepcopy(default)
|
|
|
|
# 1) 修 openclaw.json
|
|
cfg = load_json(openclaw_path, {})
|
|
cfg.setdefault("tools", {})
|
|
cfg["tools"].setdefault("exec", {})
|
|
cfg["tools"]["exec"]["security"] = "full"
|
|
cfg["tools"]["exec"]["ask"] = "off"
|
|
|
|
# 可选但实用:把常见会挡住 skill 的 deny 清掉
|
|
agents = cfg.get("agents", {}).get("list", [])
|
|
if isinstance(agents, list):
|
|
for agent in agents:
|
|
if not isinstance(agent, dict):
|
|
continue
|
|
tools = agent.setdefault("tools", {})
|
|
deny = tools.get("deny", [])
|
|
if isinstance(deny, list):
|
|
tools["deny"] = []
|
|
|
|
openclaw_path.write_text(json.dumps(cfg, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
|
|
# 2) 修 exec-approvals.json
|
|
default_approvals = {
|
|
"version": 1,
|
|
"socket": {
|
|
"path": str(base / "exec-approvals.sock"),
|
|
"token": ""
|
|
},
|
|
"defaults": {
|
|
"security": "full",
|
|
"ask": "off",
|
|
"askFallback": "full",
|
|
"autoAllowSkills": True
|
|
},
|
|
"agents": {}
|
|
}
|
|
|
|
ap = load_json(approvals_path, default_approvals)
|
|
|
|
# 保留已有 socket,避免你本机原来的 socket/token 被抹掉
|
|
if not isinstance(ap, dict):
|
|
ap = copy.deepcopy(default_approvals)
|
|
|
|
ap["version"] = 1
|
|
ap.setdefault("socket", {})
|
|
ap["socket"].setdefault("path", str(base / "exec-approvals.sock"))
|
|
ap["socket"].setdefault("token", "")
|
|
|
|
ap.setdefault("defaults", {})
|
|
ap["defaults"]["security"] = "full"
|
|
ap["defaults"]["ask"] = "off"
|
|
ap["defaults"]["askFallback"] = "full"
|
|
ap["defaults"]["autoAllowSkills"] = True
|
|
|
|
ap.setdefault("agents", {})
|
|
if isinstance(ap["agents"], dict):
|
|
for agent_name, agent_cfg in list(ap["agents"].items()):
|
|
if isinstance(agent_cfg, dict):
|
|
agent_cfg["security"] = "full"
|
|
agent_cfg["ask"] = "off"
|
|
agent_cfg["askFallback"] = "full"
|
|
agent_cfg["autoAllowSkills"] = True
|
|
|
|
approvals_path.write_text(json.dumps(ap, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
|
|
print("DONE")
|
|
print(openclaw_path)
|
|
print(approvals_path)
|
|
PY
|
|
|
|
openclaw gateway start
|
|
echo '----- GATEWAY STATUS -----'
|
|
openclaw gateway status
|
|
echo '----- APPROVALS EFFECTIVE -----'
|
|
openclaw approvals get --gateway || true
|
|
echo '----- OPENCLAW EXEC CONFIG -----'
|
|
python3 - <<'PY'
|
|
import json, os, pathlib
|
|
p = pathlib.Path(os.path.expanduser("~/.openclaw/openclaw.json"))
|
|
cfg = json.loads(p.read_text(encoding="utf-8"))
|
|
print(json.dumps(cfg.get("tools", {}).get("exec", {}), ensure_ascii=False, indent=2))
|
|
PY |