fix(admin): run_command toggle GET matches DB absent; add disabled hint

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-05-12 19:17:13 +08:00
parent 274a9b8ddd
commit 5b2f182ae4
3 changed files with 25 additions and 4 deletions

View file

@ -99,9 +99,23 @@ class LocalAdapter:
raw_env = str(os.getenv("AIA_ENABLE_RUN_COMMAND") or "").strip()
enabled = _truthy(raw_env) if raw_env else False
if not enabled:
return {"ok": False, "error_code": "disabled", "error": "disabled"}
return {
"ok": False,
"error_code": "disabled",
"error": "disabled",
"hint": (
"run_command is off: save Admin → Tool policy with run_command enabled (writes AIA_ENABLE_RUN_COMMAND "
"into the same SQLite the gateway uses), or set env AIA_ENABLE_RUN_COMMAND=1. "
"Check OPS_ASSISTANT_DB_PATH / db_path() if another machine uses a different DB file."
),
}
except Exception:
return {"ok": False, "error_code": "disabled", "error": "disabled"}
return {
"ok": False,
"error_code": "disabled",
"error": "disabled",
"hint": "run_command gate failed unexpectedly; check gateway logs and SQLite app_setting access.",
}
try:
timeout_s = max(1, min(int(timeout or 300), 600))
# run_command never follows adapter cd state.