Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ async def get_update_dry_run():
latest: Optional[str] = None
changelog_url: Optional[str] = None
update_available = False
version_check_error: Optional[str] = None

try:
req = urllib.request.Request(
Expand All @@ -241,8 +242,8 @@ async def get_update_dry_run():
def _parts(v: str) -> list[int]:
return ([int(x) for x in v.split(".") if x.isdigit()][:3] + [0, 0, 0])[:3]
update_available = _parts(latest) > _parts(current)
except (urllib.error.URLError, urllib.error.HTTPError, OSError, json.JSONDecodeError, ValueError):
pass
except (urllib.error.URLError, urllib.error.HTTPError, OSError, json.JSONDecodeError, ValueError) as e:
version_check_error = f"Could not reach GitHub: {e}"

# ── configured image tags from compose files ──────────────────────────────
images: list[str] = []
Expand Down Expand Up @@ -276,6 +277,7 @@ def _parts(v: str) -> list[int]:
"changelog_url": changelog_url,
"images": images,
"env_keys": env_snapshot,
"version_check_error": version_check_error,
}


Expand Down
8 changes: 6 additions & 2 deletions dream-server/extensions/services/token-spy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ async def _handle_non_streaming(client, raw_body, headers, model, sys_analysis,
try:
data = resp.json()
except Exception:
log.warning("Failed to parse Anthropic response JSON — token usage will be recorded as zero")
data = {}

resp_usage = data.get("usage", {})
Expand Down Expand Up @@ -942,6 +943,7 @@ async def _handle_openai_non_streaming(client, raw_body, headers, model, sys_ana
try:
data = resp.json()
except Exception:
log.warning("Failed to parse OpenAI response JSON — token usage will be recorded as zero")
data = {}

resp_usage = data.get("usage", {})
Expand Down Expand Up @@ -1184,7 +1186,8 @@ def _get_remote_session_status(agent: str) -> dict:
" history_chars += sum(len(str(x)) for x in c)\n"
" elif isinstance(c, str):\n"
" history_chars += len(c)\n"
" except: pass\n"
" except Exception:\n"
" pass # skip corrupt JSONL lines\n"
" print(json.dumps({'turns': turns, 'chars': history_chars, 'tool_results': tool_results,"
" 'file_bytes': os.path.getsize(largest), 'total_lines': len(lines), 'files': len(files)}))"
)
Expand Down Expand Up @@ -1266,7 +1269,8 @@ def _kill_remote_session(agent: str, reason: str = "dashboard") -> dict:
" for k in list(data.keys()):\n"
" if isinstance(data[k], dict) and data[k].get('sessionId') == sid: del data[k]\n"
" with open(sj, 'w') as fh: json.dump(data, fh, indent=2)\n"
" except: pass\n"
" except Exception as e:\n"
" print(json.dumps({'warn': 'sessions.json update failed', 'error': str(e)}))\n"
" print(json.dumps({'action': 'killed', 'session_id': sid, 'size_bytes': size}))"
)
try:
Expand Down
16 changes: 11 additions & 5 deletions dream-server/installers/phases/06-directories.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,16 @@ Fix with: sudo chown -R \$(id -u):\$(id -g) $INSTALL_DIR/config $INSTALL_DIR/dat
"$SCRIPT_DIR/" "$INSTALL_DIR/"
else
# Fallback: cp -r everything, then remove runtime artifacts
cp -r "$SCRIPT_DIR"/* "$INSTALL_DIR/" 2>/dev/null || true
cp "$SCRIPT_DIR"/.gitignore "$INSTALL_DIR/" 2>/dev/null || true
rm -rf "$INSTALL_DIR/.git" 2>/dev/null || true
if ! cp -r "$SCRIPT_DIR"/* "$INSTALL_DIR/" 2>>"$LOG_FILE"; then
warn "Source copy incomplete — some files may be missing"
fi
if ! cp "$SCRIPT_DIR"/.gitignore "$INSTALL_DIR/" 2>>"$LOG_FILE"; then
warn "Failed to copy .gitignore"
fi
rm -rf "$INSTALL_DIR/.git" 2>>"$LOG_FILE" || true
fi
# Ensure scripts are executable
chmod +x "$INSTALL_DIR"/*.sh "$INSTALL_DIR"/scripts/*.sh "$INSTALL_DIR"/dream-cli 2>/dev/null || true
chmod +x "$INSTALL_DIR"/*.sh "$INSTALL_DIR"/scripts/*.sh "$INSTALL_DIR"/dream-cli 2>>"$LOG_FILE" || warn "Some scripts may not be executable — verify after install"
ai_ok "Source files installed"
else
log "Running in-place (source == install dir), skipping file copy"
Expand All @@ -124,7 +128,9 @@ Fix with: sudo chown -R \$(id -u):\$(id -g) $INSTALL_DIR/config $INSTALL_DIR/dat
cp "$SCRIPT_DIR/config/openclaw/$OPENCLAW_CONFIG" "$INSTALL_DIR/config/openclaw/openclaw.json"
else
warn "OpenClaw config $OPENCLAW_CONFIG not found, using default"
cp "$SCRIPT_DIR/config/openclaw/openclaw.json.example" "$INSTALL_DIR/config/openclaw/openclaw.json" 2>/dev/null || true
if ! cp "$SCRIPT_DIR/config/openclaw/openclaw.json.example" "$INSTALL_DIR/config/openclaw/openclaw.json" 2>>"$LOG_FILE"; then
warn "Failed to copy OpenClaw default config — you may need to create it manually"
fi
fi
# Resolve provider name/URL before any sed replacements that depend on them
OPENCLAW_PROVIDER_NAME="${OPENCLAW_PROVIDER_NAME_DEFAULT}"
Expand Down
19 changes: 15 additions & 4 deletions dream-server/installers/phases/11-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,21 @@ MODELS_INI_EOF
if [[ "$_BOOTSTRAP_ACTIVE" == "true" ]]; then
_env_file="$INSTALL_DIR/.env"
if [[ -f "$_env_file" ]]; then
awk -v v="$GGUF_FILE" '{ if (index($0, "GGUF_FILE=") == 1) print "GGUF_FILE=" v; else print }' "$_env_file" > "${_env_file}.tmp" && cat "${_env_file}.tmp" > "$_env_file" && rm -f "${_env_file}.tmp"
awk -v v="$LLM_MODEL" '{ if (index($0, "LLM_MODEL=") == 1) print "LLM_MODEL=" v; else print }' "$_env_file" > "${_env_file}.tmp" && cat "${_env_file}.tmp" > "$_env_file" && rm -f "${_env_file}.tmp"
awk -v v="$MAX_CONTEXT" '{ if (index($0, "MAX_CONTEXT=") == 1) print "MAX_CONTEXT=" v; else print }' "$_env_file" > "${_env_file}.tmp" && cat "${_env_file}.tmp" > "$_env_file" && rm -f "${_env_file}.tmp"
ai_ok "Patched .env for bootstrap model ($GGUF_FILE)"
_env_patch_ok=true
for _key_val in "GGUF_FILE=$GGUF_FILE" "LLM_MODEL=$LLM_MODEL" "MAX_CONTEXT=$MAX_CONTEXT"; do
_key="${_key_val%%=*}"
_val="${_key_val#*=}"
if ! awk -v v="$_val" '{ if (index($0, "'"$_key"'=") == 1) print "'"$_key"'=" v; else print }' \
"$_env_file" > "${_env_file}.tmp" 2>>"$LOG_FILE" \
&& cat "${_env_file}.tmp" > "$_env_file" 2>>"$LOG_FILE" \
&& rm -f "${_env_file}.tmp"; then
_env_patch_ok=false
warn "Failed to patch $_key in .env"
fi
done
if [[ "$_env_patch_ok" == "true" ]]; then
ai_ok "Patched .env for bootstrap model ($GGUF_FILE)"
fi
fi
fi
fi
Expand Down
Loading