feat(android-agent): APK von ARIA empfangen und installieren
Neues Brain-Tool host_install_apk: ARIA schickt eine APK unter /shared/ an einen Android-Agenten, der Installationsdialog von Android oeffnet sich. - Bridge: file_request kann mit offset/length einzelne Stuecke liefern (max. 8 MB); der bisherige Abruf am Stueck bleibt unveraendert - Agent: holt die APK in 4-MB-Stuecken (gezielte file_response vom RVS, nicht an alle im Raum), prueft sha256, oeffnet den Dialog direkt oder per Benachrichtigung; prueft "Unbekannte Apps installieren" vor dem Download - Still installieren geht nicht (Android-Regel), Bestaetigung am Geraet noetig - README: Abschnitt beim Android-Agenten Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+54
-1
@@ -1838,6 +1838,31 @@ META_TOOLS = [
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "host_install_apk",
|
||||
"description": (
|
||||
"Installiert eine APK auf einem Android-Agenten (Handy, Tablet, "
|
||||
"Fire TV). Die APK muss unter /shared/ liegen; der Agent holt sie "
|
||||
"ueber den RVS und oeffnet den Installationsdialog von Android. "
|
||||
"STILL installieren geht nicht: am Geraet muss jemand 'Installieren' "
|
||||
"bestaetigen (Android-Regel). Beim ersten Mal muss dort ausserdem "
|
||||
"'Unbekannte Apps installieren' fuer den ARIA Host-Agent erlaubt "
|
||||
"werden. Ob die Installation durch ist, pruefst Du danach z.B. mit "
|
||||
"host_app_launch oder einem Screenshot. Braucht 'Steuerung erlauben' "
|
||||
"am Geraet."
|
||||
),
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"host": {"type": "string", "description": "Host-ID/Name (siehe host_list)."},
|
||||
"path": {"type": "string", "description": "Pfad der APK unter /shared/, z.B. /shared/uploads/app.apk."},
|
||||
},
|
||||
"required": ["host", "path"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
@@ -3843,6 +3868,33 @@ class Agent:
|
||||
+ json.dumps(nodes, ensure_ascii=False, indent=2)
|
||||
)
|
||||
|
||||
if name == "host_install_apk":
|
||||
apk = os.path.realpath((arguments.get("path") or "").strip())
|
||||
if not apk.startswith("/shared/") or not apk.lower().endswith(".apk"):
|
||||
return "FEHLER: path muss eine .apk unter /shared/ sein."
|
||||
if not os.path.isfile(apk):
|
||||
return f"FEHLER: APK nicht gefunden: {apk}"
|
||||
import hashlib as _hl
|
||||
size = os.path.getsize(apk)
|
||||
h = _hl.sha256()
|
||||
with open(apk, "rb") as _f:
|
||||
for _blk in iter(lambda: _f.read(1024 * 1024), b""):
|
||||
h.update(_blk)
|
||||
# Der Agent holt die Datei stueckweise — Zeit nach Groesse
|
||||
# bemessen (grob 3 s pro MB, mindestens 2 Minuten).
|
||||
_timeout = min(1800, 120 + 3 * (size // (1024 * 1024)))
|
||||
result = _post("/internal/host",
|
||||
{"host": host, "action": "apk_install",
|
||||
"params": {"path": apk, "size": size,
|
||||
"sha256": h.hexdigest(),
|
||||
"name": os.path.basename(apk)},
|
||||
"timeout": _timeout},
|
||||
_timeout + 10)
|
||||
if not result.get("ok"):
|
||||
return f"FEHLER: {result.get('error')}"
|
||||
r = result.get("result") or {}
|
||||
return f"OK ({host}): {r.get('message', 'Installation angestossen')}"
|
||||
|
||||
# ── Steuern (Meilenstein 3) ──────────────────────────────
|
||||
_UI_ACTIONS = {
|
||||
"host_ui_tap": ("ui_tap", ["x", "y", "button", "double"]),
|
||||
@@ -4860,7 +4912,8 @@ class Agent:
|
||||
"host_info", "host_screenshot", "host_ui_dump",
|
||||
"host_ui_tap", "host_ui_text", "host_ui_swipe",
|
||||
"host_ui_key", "host_app_launch",
|
||||
"host_notify", "host_speak", "host_volume"):
|
||||
"host_notify", "host_speak", "host_volume",
|
||||
"host_install_apk"):
|
||||
return self._dispatch_host(name, arguments)
|
||||
if name == "vm_register":
|
||||
pid = (project_id or "").strip()
|
||||
|
||||
Reference in New Issue
Block a user