[STAGE5] Migrate HomeBot to gateway local-tools
This commit is contained in:
1 parent
c7be3583e1
commit
7e30c8df13
5 files changed
+30
-3
No files matched your search
@@ -28,6 +28,9 @@ direct 127.0.0.1:9120 → blocked
|
||||
- feature flag `HUB_GATEWAY_BOOK=1` включён;
|
||||
- `book.stats` через gateway: 41 книга;
|
||||
- `book.recent/search` падают на `/opt/books/...` — путь сломан и в прямом режиме;
|
||||
- `HomeBot` мигрирован на gateway (`home.stats`, `home.status`);
|
||||
- feature flag `HUB_GATEWAY_HOME=1` включён;
|
||||
- `home.stats` 646 сущностей, `home.status` 77 states;
|
||||
- hub-bots active, 9 ботов на связи.
|
||||
|
||||
## Порядок миграции
|
||||
|
||||
@@ -45,6 +45,14 @@ tools:
|
||||
mode: read
|
||||
local: book_search
|
||||
approval: false
|
||||
- name: home.stats
|
||||
mode: read
|
||||
local: home_stats
|
||||
approval: false
|
||||
- name: home.status
|
||||
mode: read
|
||||
local: home_status
|
||||
approval: false
|
||||
- name: audit.write
|
||||
gateway: http://127.0.0.1:9160/api/sprint/status
|
||||
mode: write
|
||||
|
||||
@@ -27,7 +27,7 @@ GET /v1/models
|
||||
| S5-04 | Memory | done: SQLite namespaced memory + TTL/search, tests 3/3 |
|
||||
| S5-05 | Night Shift | done: timers 00:00/07:30, llm-night-start/stop |
|
||||
| S5-06 | Tool Gateway / agent approvals | done: agent-gw enforced + approval queue; legacy migration = G5 |
|
||||
| S5-07 | Gate G5 | in_progress: Photo+Book migrated; остальные боты direct |
|
||||
| S5-07 | Gate G5 | in_progress: Photo+Book+Home migrated; остальные direct |
|
||||
|
||||
## Tool Gateway runtime
|
||||
|
||||
|
||||
@@ -52,6 +52,12 @@ def local_call(handler, q=""):
|
||||
if handler == "book_search":
|
||||
rows, err = _photo_local().Books().search(q, 5)
|
||||
return {"ok": not bool(err), "rows": rows, "error": err}
|
||||
if handler == "home_stats":
|
||||
data, err = _photo_local().HomeDb().entities()
|
||||
return {"ok": not bool(err), "data": data, "error": err}
|
||||
if handler == "home_status":
|
||||
data, err = _photo_local().HomeDb().states()
|
||||
return {"ok": not bool(err), "data": data, "error": err}
|
||||
raise ValueError("unknown local handler")
|
||||
|
||||
|
||||
|
||||
+12
-2
@@ -926,7 +926,12 @@ class HomeBot(Bot):
|
||||
self.cmd("status", "кратко о состоянии дома")(lambda a: self._status())
|
||||
|
||||
def _stats(self):
|
||||
data, err = local.HomeDb().entities()
|
||||
if os.environ.get("HUB_GATEWAY_HOME") == "1":
|
||||
from .gateway import call
|
||||
d = call("home.stats")
|
||||
data, err = d.get("data"), d.get("error")
|
||||
else:
|
||||
data, err = local.HomeDb().entities()
|
||||
if err:
|
||||
return f"Не смог прочитать реестр HA: {err}"
|
||||
lines = ["**Дом**", "", f"• Устройств и сущностей: {data['total']}"]
|
||||
@@ -939,7 +944,12 @@ class HomeBot(Bot):
|
||||
return "\n".join(lines)
|
||||
|
||||
def _status(self):
|
||||
data, err = local.HomeDb().states()
|
||||
if os.environ.get("HUB_GATEWAY_HOME") == "1":
|
||||
from .gateway import call
|
||||
d = call("home.status")
|
||||
data, err = d.get("data"), d.get("error")
|
||||
else:
|
||||
data, err = local.HomeDb().states()
|
||||
if err:
|
||||
return f"Не удалось прочитать состояние: {err}"
|
||||
return (f"**Состояние дома**\n\n• Запомненных состояний: {data['restored']}\n\n"
|
||||
|
||||
Reference in new issue
Block a user