feat: update version to 0.5.60 and enhance session lock cleanup for non-default agents
This commit is contained in:
@@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
All notable changes to the OpenClaw Assistant Home Assistant Add-on will be documented in this file.
|
All notable changes to the OpenClaw Assistant Home Assistant Add-on will be documented in this file.
|
||||||
|
|
||||||
|
## [0.5.60] - 2026-03-10
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- **Session lock cleanup ignored non-default agents**: `cleanup_session_locks` was hardcoded to `agents/main/sessions`, skipping stale locks for any agent with a custom `forcedAgentId`. Stale locks could block the gateway from opening sessions for those agents, causing silent fallback to `main`. Cleanup now scans all `agents/*/sessions/` directories.
|
||||||
|
|
||||||
## [0.5.59] - 2026-03-10
|
## [0.5.59] - 2026-03-10
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- **Gateway restart loop** (issue #95): when the agent or user ran `openclaw gateway restart`, the supervisor loop detected the old PID exiting and immediately spawned a second gateway instance, which collided with the already-restarted one and looped with "another gateway instance is already listening". The supervisor now detects a self-restart (new PID already running on the same port) and re-tracks it instead of spawning a duplicate.
|
- **Gateway restart loop** (issue #95): when the agent or user ran `openclaw gateway restart`, the supervisor loop detected the old PID exiting and immediately spawned a second gateway instance, which collided with the already-restarted one and looped with "another gateway instance is already listening". The supervisor now detects a self-restart (new PID already running on the same port) and re-tracks it instead of spawning a duplicate.
|
||||||
- **Remote mode URL not propagated** (issue #93): `start_openclaw_runtime` was reading `gateway.remote.url` back via `openclaw config get`, which can time out (2 s limit at startup) or return an empty/redacted result. The function now uses `$GATEWAY_REMOTE_URL` directly from the already-parsed add-on options, which is the same value the config helper writes to `openclaw.json`.
|
- **Remote mode URL not propagated** (issue #93): `start_openclaw_runtime` was reading `gateway.remote.url` back via `openclaw config get`, which can time out (2 s limit at startup) or return an empty/redacted result. The function now uses `$GATEWAY_REMOTE_URL` directly from the already-parsed add-on options, which is the same value the config helper writes to `openclaw.json`.
|
||||||
- **Terminal CLI unreachable in tailnet mode** (issue #90): when `gateway_bind_mode=tailnet` (or `access_mode=tailnet_https`), the gateway binds only to the Tailscale IP. The local CLI always connects via `ws://127.0.0.1:PORT`, causing "Gateway not running" inside the add-on terminal. A lightweight loopback relay (Node.js) is now started automatically to forward `127.0.0.1:PORT → TAILSCALE_IP:PORT`, making all terminal CLI commands work normally. Token auth is still enforced end-to-end by the gateway.
|
- **Terminal CLI unreachable in tailnet mode** (issue #90): when `gateway_bind_mode=tailnet` (or `access_mode=tailnet_https`), the gateway binds only to the Tailscale IP. The local CLI always connects via `ws://127.0.0.1:PORT`, causing "Gateway not running" inside the add-on terminal. A lightweight loopback relay (Node.js) is now started automatically to forward `127.0.0.1:PORT → TAILSCALE_IP:PORT`, making all terminal CLI commands work normally. Token auth is still enforced end-to-end by the gateway.
|
||||||
|
- **Session lock cleanup ignored non-default agents**: `cleanup_session_locks` was hardcoded to `agents/main/sessions`, skipping stale locks for any agent with a custom `forcedAgentId`. Stale locks could block the gateway from opening sessions for those agents, causing silent fallback to `main`. Cleanup now scans all `agents/*/sessions/` directories.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- **MCP auto-configuration for Home Assistant**: new option `auto_configure_mcp` (default: `false`). When enabled and `homeassistant_token` is set, the add-on automatically registers Home Assistant as an MCP server (`mcporter config add HA ...`) on startup. Auto-detects the HA API URL (supervisor proxy or localhost:8123). Re-configures only when the token changes.
|
- **MCP auto-configuration for Home Assistant**: new option `auto_configure_mcp` (default: `false`). When enabled and `homeassistant_token` is set, the add-on automatically registers Home Assistant as an MCP server (`mcporter config add HA ...`) on startup. Auto-detects the HA API URL (supervisor proxy or localhost:8123). Re-configures only when the token changes.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: OpenClaw Assistant
|
name: OpenClaw Assistant
|
||||||
version: "0.5.59"
|
version: "0.5.60"
|
||||||
slug: openclaw_assistant
|
slug: openclaw_assistant
|
||||||
description: Run OpenClaw Assistant (OpenClaw-compatible) as a Home Assistant add-on.
|
description: Run OpenClaw Assistant (OpenClaw-compatible) as a Home Assistant add-on.
|
||||||
url: https://github.com/techartdev/OpenClawHomeAssistant
|
url: https://github.com/techartdev/OpenClawHomeAssistant
|
||||||
|
|||||||
@@ -374,8 +374,9 @@ if [ ! -e /data ]; then
|
|||||||
ln -s /config /data || true
|
ln -s /config /data || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure these exist so cleanup doesn't fail
|
# Ensure the agents base directory exists so cleanup scans work even before first run.
|
||||||
mkdir -p /config/.openclaw/agents/main/sessions || true
|
# Do NOT pre-create agent-specific directories; OpenClaw creates them as needed.
|
||||||
|
mkdir -p /config/.openclaw/agents || true
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# SINGLE-INSTANCE GUARD (prevents multiple gateway runs racing each other)
|
# SINGLE-INSTANCE GUARD (prevents multiple gateway runs racing each other)
|
||||||
@@ -397,26 +398,39 @@ gateway_running() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup_session_locks() {
|
cleanup_session_locks() {
|
||||||
local sessions_dir="/config/.openclaw/agents/main/sessions"
|
local agents_dir="/config/.openclaw/agents"
|
||||||
local glob1="${sessions_dir}"/*.jsonl.lock
|
local total_locks=0
|
||||||
|
local cleaned_dirs=()
|
||||||
|
|
||||||
|
# Scan all agent session directories, not just 'main'.
|
||||||
|
# This is needed for users who have gateway.forcedAgentId set to a non-default agent.
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
local locks=( $glob1 )
|
local all_locks=()
|
||||||
|
for agent_sessions_dir in "${agents_dir}"/*/sessions; do
|
||||||
|
local agent_locks=( "${agent_sessions_dir}"/*.jsonl.lock )
|
||||||
|
if [ ${#agent_locks[@]} -gt 0 ]; then
|
||||||
|
all_locks+=( "${agent_locks[@]}" )
|
||||||
|
cleaned_dirs+=( "$agent_sessions_dir" )
|
||||||
|
total_locks=$(( total_locks + ${#agent_locks[@]} ))
|
||||||
|
fi
|
||||||
|
done
|
||||||
shopt -u nullglob
|
shopt -u nullglob
|
||||||
|
|
||||||
if [ ${#locks[@]} -eq 0 ]; then
|
if [ "$total_locks" -eq 0 ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If gateway is running, do NOT remove locks automatically (could be real).
|
# If gateway is running, do NOT remove locks automatically (could be real).
|
||||||
if gateway_running; then
|
if gateway_running; then
|
||||||
echo "INFO: Gateway appears to be running; leaving session lock files untouched."
|
echo "INFO: Gateway appears to be running; leaving session lock files untouched."
|
||||||
echo "INFO: Locks present: ${#locks[@]}"
|
echo "INFO: Locks present: $total_locks"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "INFO: Removing stale session lock files (${#locks[@]}) from ${sessions_dir}"
|
echo "INFO: Removing stale session lock files ($total_locks) across agents: ${cleaned_dirs[*]}"
|
||||||
rm -f "${sessions_dir}"/*.jsonl.lock || true
|
for agent_sessions_dir in "${cleaned_dirs[@]}"; do
|
||||||
|
rm -f "${agent_sessions_dir}"/*.jsonl.lock || true
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$CLEAN_LOCKS_ON_START" = "true" ]; then
|
if [ "$CLEAN_LOCKS_ON_START" = "true" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user