[STAGE5] Migrate CamBot read tools
This commit is contained in:
1 parent
8f50032e80
commit
6c0ffecb09
5 files changed
+34
-1
No files matched your search
@@ -38,6 +38,8 @@ direct 127.0.0.1:9120 → blocked
|
||||
- feature flag `HUB_GATEWAY_SEARCH=1` включён;
|
||||
- `!reindex` в gateway-режиме отключён;
|
||||
- Jellyfin/Paperless 401 — отдельные auth-проблемы;
|
||||
- `CamBot` мигрирован на gateway (`cam.scan`, `cam.status`), read-only;
|
||||
- feature flag `HUB_GATEWAY_CAM=1` включён; камера не перенастраивалась;
|
||||
- hub-bots active, 9 ботов на связи.
|
||||
|
||||
## Порядок миграции
|
||||
|
||||
@@ -109,6 +109,14 @@ tools:
|
||||
mode: read
|
||||
local: paperless_search
|
||||
approval: false
|
||||
- name: cam.scan
|
||||
mode: read
|
||||
local: cam_scan
|
||||
approval: false
|
||||
- name: cam.status
|
||||
mode: read
|
||||
local: cam_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+Home+Digest+Search; MEDIA/INFRA/CAM/SECRETARY direct |
|
||||
| S5-07 | Gate G5 | in_progress: Photo+Book+Home+Digest+Search+Cam; MEDIA/INFRA/SECRETARY direct |
|
||||
|
||||
## Tool Gateway runtime
|
||||
|
||||
|
||||
@@ -107,6 +107,14 @@ def local_call(handler, q=""):
|
||||
f"{sources.CFG.paperless_url}/api/documents/?query={sources.util.quote(q)}&page_size=5",
|
||||
{"Authorization": f"Token {sources.CFG.paperless_token}"}, ttl=60)
|
||||
return {"ok": not bool(err), "data": data, "error": err}
|
||||
if handler == "cam_scan":
|
||||
import subprocess
|
||||
r = subprocess.run(["/usr/bin/python3", "/opt/hub-core/camera_discover.py"],
|
||||
capture_output=True, text=True, timeout=120)
|
||||
return {"ok": r.returncode == 0, "data": (r.stdout or "").strip(), "error": (r.stderr or "")[:200]}
|
||||
if handler == "cam_status":
|
||||
bot = _hub_module("bots").CamBot(None, None)
|
||||
return {"ok": True, "data": bot._cam_status(), "error": None}
|
||||
raise ValueError("unknown local handler")
|
||||
|
||||
|
||||
|
||||
@@ -1555,6 +1555,18 @@ class CamBot(Bot):
|
||||
|
||||
def _cam_scan(self):
|
||||
"""Найти камеры в сети (порт 554 и другие)."""
|
||||
if os.environ.get("HUB_GATEWAY_CAM") == "1":
|
||||
from .gateway import call
|
||||
text = (call("cam.scan").get("data") or "").strip()
|
||||
if not text:
|
||||
return "Поиск ничего не вернул."
|
||||
lines = text.splitlines()
|
||||
head = [l for l in lines if l.startswith(("соседей", "похоже", "с открытыми"))]
|
||||
found = [l for l in lines if l.startswith(" ") and "порты" in l]
|
||||
res = ["**Поиск камер в сети**", ""] + head
|
||||
if found:
|
||||
res += [""] + found[:10]
|
||||
return "\n".join(res)
|
||||
import subprocess
|
||||
try:
|
||||
out = subprocess.run(['/usr/bin/python3', '/opt/hub-core/camera_discover.py'],
|
||||
@@ -1574,6 +1586,9 @@ class CamBot(Bot):
|
||||
|
||||
def _cam_status(self):
|
||||
"""Что известно про камеры: Frigate и последний поиск."""
|
||||
if os.environ.get("HUB_GATEWAY_CAM") == "1":
|
||||
from .gateway import call
|
||||
return call("cam.status").get("data") or "Нет данных."
|
||||
lines = []
|
||||
try:
|
||||
data, err = util.get('http://192.168.1.126:5000/api/stats')
|
||||
|
||||
Reference in new issue
Block a user