Generate strict JSON config and bump version to 0.3.3
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
name: Moltbot Assistant
|
name: Moltbot Assistant
|
||||||
version: "0.3.2"
|
version: "0.3.3"
|
||||||
slug: moltbot_assistant
|
slug: moltbot_assistant
|
||||||
description: Run Moltbot Assistant (Clawdbot-compatible) as a Home Assistant add-on.
|
description: Run Moltbot Assistant (Clawdbot-compatible) as a Home Assistant add-on.
|
||||||
url: https://github.com/techartdev/ClawdHAAddOn
|
url: https://github.com/techartdev/ClawdHAAddOn
|
||||||
|
|||||||
+46
-29
@@ -137,40 +137,57 @@ if [ -z "$GW_TOKEN" ]; then
|
|||||||
GW_AUTH_BLOCK="auth: { mode: \"token\" }"
|
GW_AUTH_BLOCK="auth: { mode: \"token\" }"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Write Clawdbot gateway config (JSON5) into the expected location.
|
# Write Clawdbot gateway config (strict JSON) into the expected location.
|
||||||
cat > /config/.clawdbot/clawdbot.json <<EOF
|
# We generate JSON with python to avoid JSON5-only syntax and comma edge cases.
|
||||||
{
|
GW_BIND="$GW_BIND" GW_PORT="$GW_PORT" MODEL_PRIMARY="$MODEL_PRIMARY" \
|
||||||
discovery: { wideArea: { enabled: false } },
|
BOT_TOKEN="$BOT_TOKEN" DM_POLICY="$DM_POLICY" ALLOW_FROM_JSON='${ALLOW_FROM_JSON:-}' \
|
||||||
|
python3 - <<'PY'
|
||||||
|
import json, os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
gateway: {
|
cfg = {
|
||||||
mode: "local",
|
"discovery": {"wideArea": {"enabled": False}},
|
||||||
bind: "${GW_BIND}",
|
"gateway": {
|
||||||
port: ${GW_PORT},
|
"mode": "local",
|
||||||
controlUi: { allowInsecureAuth: true },
|
"bind": os.environ["GW_BIND"],
|
||||||
${GW_AUTH_BLOCK}
|
"port": int(os.environ["GW_PORT"]),
|
||||||
|
"controlUi": {"allowInsecureAuth": True},
|
||||||
},
|
},
|
||||||
agents: {
|
"agents": {
|
||||||
defaults: {
|
"defaults": {
|
||||||
workspace: "/config/clawd",
|
"workspace": "/config/clawd",
|
||||||
model: { primary: "${MODEL_PRIMARY}" },
|
"model": {"primary": os.environ["MODEL_PRIMARY"]},
|
||||||
models: {
|
"models": {os.environ["MODEL_PRIMARY"]: {}},
|
||||||
"${MODEL_PRIMARY}": {}
|
},
|
||||||
|
"list": [{"id": "main"}],
|
||||||
|
},
|
||||||
|
"channels": {
|
||||||
|
"telegram": {
|
||||||
|
"enabled": True,
|
||||||
|
"botToken": os.environ["BOT_TOKEN"],
|
||||||
|
"dmPolicy": os.environ["DM_POLICY"],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
list: [
|
|
||||||
{ id: "main" }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
channels: {
|
|
||||||
telegram: {
|
|
||||||
enabled: true,
|
|
||||||
botToken: "${BOT_TOKEN}",
|
|
||||||
dmPolicy: "${DM_POLICY}"${ALLOW_FROM_RAW:+,
|
|
||||||
allowFrom: ${ALLOW_FROM_JSON}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
|
allow_from_json = os.environ.get("ALLOW_FROM_JSON", "").strip()
|
||||||
|
if allow_from_json:
|
||||||
|
try:
|
||||||
|
allow_from = json.loads(allow_from_json)
|
||||||
|
if isinstance(allow_from, list) and allow_from:
|
||||||
|
cfg["channels"]["telegram"]["allowFrom"] = allow_from
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Auth block: embed token when provided, otherwise keep mode=token (auto-generate).
|
||||||
|
token = os.environ.get("GW_TOKEN", "").strip()
|
||||||
|
if token:
|
||||||
|
cfg["gateway"]["auth"] = {"mode": "token", "token": token}
|
||||||
|
else:
|
||||||
|
cfg["gateway"]["auth"] = {"mode": "token"}
|
||||||
|
|
||||||
|
Path('/config/.clawdbot/clawdbot.json').write_text(json.dumps(cfg, indent=2) + "\n")
|
||||||
|
PY
|
||||||
|
|
||||||
echo "Model primary=${MODEL_PRIMARY}"
|
echo "Model primary=${MODEL_PRIMARY}"
|
||||||
echo "Gateway bind=${GW_BIND} port=${GW_PORT} token=${GW_TOKEN:+(set)}${GW_TOKEN:-(auto)}"
|
echo "Gateway bind=${GW_BIND} port=${GW_PORT} token=${GW_TOKEN:+(set)}${GW_TOKEN:-(auto)}"
|
||||||
|
|||||||
Reference in New Issue
Block a user