Spaces:
Build error
Build error
Dmitry Beresnev commited on
Commit ·
d0088e6
1
Parent(s): aade3ff
fix dockerfile, supervisord and app
Browse files- Dockerfile +3 -0
- app.py +29 -8
- supervisord.conf +1 -1
Dockerfile
CHANGED
|
@@ -39,6 +39,9 @@ ENV OPENCLAW_GATEWAY_LOG_PATH=/tmp/openclaw-gateway.log
|
|
| 39 |
ENV OPENCLAW_GATEWAY_ERR_LOG_PATH=/tmp/openclaw-gateway.err.log
|
| 40 |
ENV OPENCLAW_DISABLE_BONJOUR=1
|
| 41 |
ENV OPENCLAW_DISABLE_MDNS=1
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
RUN mkdir -p /app/vault /app/.openclaw/state
|
| 44 |
|
|
|
|
| 39 |
ENV OPENCLAW_GATEWAY_ERR_LOG_PATH=/tmp/openclaw-gateway.err.log
|
| 40 |
ENV OPENCLAW_DISABLE_BONJOUR=1
|
| 41 |
ENV OPENCLAW_DISABLE_MDNS=1
|
| 42 |
+
ENV OPENCLAW_ONBOARD_NONINTERACTIVE=1
|
| 43 |
+
ENV OPENCLAW_CUSTOM_BASE_URL=https://researchengineering-agi.hf.space/v1
|
| 44 |
+
ENV OPENCLAW_CUSTOM_MODEL_ID=deepseek-chat
|
| 45 |
|
| 46 |
RUN mkdir -p /app/vault /app/.openclaw/state
|
| 47 |
|
app.py
CHANGED
|
@@ -32,6 +32,11 @@ OPENCLAW_STANDARD_UI_URL = os.getenv(
|
|
| 32 |
OPENCLAW_STANDARD_UI_PUBLIC_URL = os.getenv("OPENCLAW_STANDARD_UI_PUBLIC_URL", "/openclaw/")
|
| 33 |
OPENCLAW_GATEWAY_TOKEN = os.getenv("OPENCLAW_GATEWAY_TOKEN", "")
|
| 34 |
OPENCLAW_STATE_CONFIG_PATH = Path(os.getenv("OPENCLAW_STATE_CONFIG_PATH", "/app/.openclaw/state/openclaw.json"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
GATEWAY_BOOT_LOG_PATH = Path(os.getenv("OPENCLAW_GATEWAY_LOG_PATH", "/tmp/openclaw-gateway.log"))
|
| 36 |
GATEWAY_ERR_LOG_PATH = Path(os.getenv("OPENCLAW_GATEWAY_ERR_LOG_PATH", "/tmp/openclaw-gateway.err.log"))
|
| 37 |
EXTERNAL_GATEWAY_MANAGED = os.getenv("EXTERNAL_GATEWAY_MANAGED", "0") == "1"
|
|
@@ -333,12 +338,12 @@ def llm_chat_completion(api_base: str, prompt: str, max_tokens: int, temperature
|
|
| 333 |
return resp.json()
|
| 334 |
|
| 335 |
|
| 336 |
-
def with_token(url: str, token: str) -> str:
|
| 337 |
if not token:
|
| 338 |
return url
|
| 339 |
parts = urlsplit(url)
|
| 340 |
query = dict(parse_qsl(parts.query, keep_blank_values=True))
|
| 341 |
-
query.setdefault(
|
| 342 |
return urlunsplit((parts.scheme, parts.netloc, parts.path, urlencode(query), parts.fragment))
|
| 343 |
|
| 344 |
|
|
@@ -413,10 +418,11 @@ def resolve_ui_token() -> str:
|
|
| 413 |
# 3) Validate token candidates against browser UI endpoint.
|
| 414 |
for token in deduped:
|
| 415 |
try:
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
|
|
|
| 420 |
except Exception:
|
| 421 |
continue
|
| 422 |
|
|
@@ -424,6 +430,20 @@ def resolve_ui_token() -> str:
|
|
| 424 |
return resolve_gateway_token()
|
| 425 |
|
| 426 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
def build_strategy_frame(data: pd.DataFrame, fast_period: int, slow_period: int) -> pd.DataFrame:
|
| 428 |
frame = pd.DataFrame(index=data.index)
|
| 429 |
frame["Close"] = data["Close"]
|
|
@@ -540,7 +560,8 @@ with std_ui_status_col:
|
|
| 540 |
local_status = "Unavailable"
|
| 541 |
proxy_status = "Unavailable"
|
| 542 |
gateway_token = resolve_ui_token()
|
| 543 |
-
|
|
|
|
| 544 |
try:
|
| 545 |
ui_resp = requests.get(std_ui_url, timeout=2, allow_redirects=True)
|
| 546 |
local_ok = ui_resp.status_code < 500
|
|
@@ -571,7 +592,7 @@ with std_ui_status_col:
|
|
| 571 |
st.caption(f"Public URL: {OPENCLAW_STANDARD_UI_PUBLIC_URL}")
|
| 572 |
|
| 573 |
with std_ui_embed_col:
|
| 574 |
-
public_ui_url = with_token(OPENCLAW_STANDARD_UI_PUBLIC_URL, gateway_token)
|
| 575 |
if public_ui_url and proxy_ok:
|
| 576 |
st.caption(f"Embedded URL: {mask_token_in_url(public_ui_url)}")
|
| 577 |
components.iframe(public_ui_url, height=560, scrolling=True)
|
|
|
|
| 32 |
OPENCLAW_STANDARD_UI_PUBLIC_URL = os.getenv("OPENCLAW_STANDARD_UI_PUBLIC_URL", "/openclaw/")
|
| 33 |
OPENCLAW_GATEWAY_TOKEN = os.getenv("OPENCLAW_GATEWAY_TOKEN", "")
|
| 34 |
OPENCLAW_STATE_CONFIG_PATH = Path(os.getenv("OPENCLAW_STATE_CONFIG_PATH", "/app/.openclaw/state/openclaw.json"))
|
| 35 |
+
OPENCLAW_UI_QUERY_KEYS = [
|
| 36 |
+
k.strip()
|
| 37 |
+
for k in os.getenv("OPENCLAW_UI_QUERY_KEYS", "token,auth,access_token").split(",")
|
| 38 |
+
if k.strip()
|
| 39 |
+
]
|
| 40 |
GATEWAY_BOOT_LOG_PATH = Path(os.getenv("OPENCLAW_GATEWAY_LOG_PATH", "/tmp/openclaw-gateway.log"))
|
| 41 |
GATEWAY_ERR_LOG_PATH = Path(os.getenv("OPENCLAW_GATEWAY_ERR_LOG_PATH", "/tmp/openclaw-gateway.err.log"))
|
| 42 |
EXTERNAL_GATEWAY_MANAGED = os.getenv("EXTERNAL_GATEWAY_MANAGED", "0") == "1"
|
|
|
|
| 338 |
return resp.json()
|
| 339 |
|
| 340 |
|
| 341 |
+
def with_token(url: str, token: str, query_key: str = "token") -> str:
|
| 342 |
if not token:
|
| 343 |
return url
|
| 344 |
parts = urlsplit(url)
|
| 345 |
query = dict(parse_qsl(parts.query, keep_blank_values=True))
|
| 346 |
+
query.setdefault(query_key, token)
|
| 347 |
return urlunsplit((parts.scheme, parts.netloc, parts.path, urlencode(query), parts.fragment))
|
| 348 |
|
| 349 |
|
|
|
|
| 418 |
# 3) Validate token candidates against browser UI endpoint.
|
| 419 |
for token in deduped:
|
| 420 |
try:
|
| 421 |
+
for key in OPENCLAW_UI_QUERY_KEYS:
|
| 422 |
+
probe_url = with_token(OPENCLAW_STANDARD_UI_URL, token, key)
|
| 423 |
+
resp = requests.get(probe_url, timeout=2, allow_redirects=True)
|
| 424 |
+
if resp.status_code < 400:
|
| 425 |
+
return token
|
| 426 |
except Exception:
|
| 427 |
continue
|
| 428 |
|
|
|
|
| 430 |
return resolve_gateway_token()
|
| 431 |
|
| 432 |
|
| 433 |
+
def resolve_ui_query_key(token: str) -> str:
|
| 434 |
+
if not token:
|
| 435 |
+
return OPENCLAW_UI_QUERY_KEYS[0] if OPENCLAW_UI_QUERY_KEYS else "token"
|
| 436 |
+
for key in OPENCLAW_UI_QUERY_KEYS:
|
| 437 |
+
try:
|
| 438 |
+
probe_url = with_token(OPENCLAW_STANDARD_UI_URL, token, key)
|
| 439 |
+
resp = requests.get(probe_url, timeout=2, allow_redirects=True)
|
| 440 |
+
if resp.status_code < 400:
|
| 441 |
+
return key
|
| 442 |
+
except Exception:
|
| 443 |
+
continue
|
| 444 |
+
return OPENCLAW_UI_QUERY_KEYS[0] if OPENCLAW_UI_QUERY_KEYS else "token"
|
| 445 |
+
|
| 446 |
+
|
| 447 |
def build_strategy_frame(data: pd.DataFrame, fast_period: int, slow_period: int) -> pd.DataFrame:
|
| 448 |
frame = pd.DataFrame(index=data.index)
|
| 449 |
frame["Close"] = data["Close"]
|
|
|
|
| 560 |
local_status = "Unavailable"
|
| 561 |
proxy_status = "Unavailable"
|
| 562 |
gateway_token = resolve_ui_token()
|
| 563 |
+
gateway_query_key = resolve_ui_query_key(gateway_token)
|
| 564 |
+
std_ui_url = with_token(OPENCLAW_STANDARD_UI_URL, gateway_token, gateway_query_key)
|
| 565 |
try:
|
| 566 |
ui_resp = requests.get(std_ui_url, timeout=2, allow_redirects=True)
|
| 567 |
local_ok = ui_resp.status_code < 500
|
|
|
|
| 592 |
st.caption(f"Public URL: {OPENCLAW_STANDARD_UI_PUBLIC_URL}")
|
| 593 |
|
| 594 |
with std_ui_embed_col:
|
| 595 |
+
public_ui_url = with_token(OPENCLAW_STANDARD_UI_PUBLIC_URL, gateway_token, gateway_query_key)
|
| 596 |
if public_ui_url and proxy_ok:
|
| 597 |
st.caption(f"Embedded URL: {mask_token_in_url(public_ui_url)}")
|
| 598 |
components.iframe(public_ui_url, height=560, scrolling=True)
|
supervisord.conf
CHANGED
|
@@ -5,7 +5,7 @@ pidfile=/tmp/supervisord.pid
|
|
| 5 |
user=root
|
| 6 |
|
| 7 |
[program:openclaw]
|
| 8 |
-
command=/bin/sh -lc "python /app/scripts/bootstrap_gateway_token.py
|
| 9 |
autorestart=true
|
| 10 |
startsecs=5
|
| 11 |
startretries=20
|
|
|
|
| 5 |
user=root
|
| 6 |
|
| 7 |
[program:openclaw]
|
| 8 |
+
command=/bin/sh -lc "AUTH_FILE=/app/.openclaw/state/agents/dev/agent/auth-profiles.json; if [ \"${OPENCLAW_ONBOARD_NONINTERACTIVE:-1}\" = \"1\" ] && [ ! -s \"$AUTH_FILE\" ]; then echo '[onboard] running non-interactive setup'; openclaw onboard --non-interactive --mode local --auth-choice custom-api-key --custom-base-url \"${OPENCLAW_CUSTOM_BASE_URL}\" --custom-model-id \"${OPENCLAW_CUSTOM_MODEL_ID}\" --gateway-port 18789 --gateway-bind loopback --skip-skills --accept-risk --secret-input-mode plaintext || true; fi; python /app/scripts/bootstrap_gateway_token.py; exec openclaw gateway run --port 18789 --allow-unconfigured --dev"
|
| 9 |
autorestart=true
|
| 10 |
startsecs=5
|
| 11 |
startretries=20
|