Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4338a01aa9 | ||
|
|
f206bd797c | ||
|
|
e0e4bb5ac0 | ||
|
|
333e4a85d1 | ||
|
|
766a2c985f | ||
|
|
157d702f5b | ||
|
|
15fbc8ff9c | ||
|
|
5912e47e32 | ||
|
|
5cb2f71c41 |
@@ -97,7 +97,7 @@ ARIA hat zwei Rollen:
|
||||
| Compute-Node(s) (STT/TTS/LLM) | 1..n GPU-Rechner | `cd xtts && cp .env.example .env && docker compose up -d` |
|
||||
| Satellit(en) 🛰️ (optional) | Fremdes Netz (Büro …) | `cd satellite && cp .env.example .env && docker compose up -d --build` |
|
||||
| Host-Agent(en) 💻 (optional) | Direkt auf einem Rechner | `cd host-agent && ./build.sh` → Binary + `.env` auf den Rechner, starten (Details unten & in [`host-agent/README.md`](host-agent/README.md)) |
|
||||
| Android-Agent 📱📺 (optional) | Handy, Tablet, Fire TV | `cd host-agent/android && ./build.sh` → APK, oder per Satellit via ADB ausrollen (Details unten) |
|
||||
| Android-Agent 📱📺 (optional) | Handy, Tablet, Fire TV | `cd host-agent/android && ./build.sh` → APK, oder per Satellit via ADB bzw. per MDM ausrollen (Details unten) |
|
||||
| Android App | Stefans Handy | APK installieren (Auto-Update via RVS) |
|
||||
|
||||
> Compute-Nodes sind optional: ohne sie faellt STT auf lokales Whisper (CPU,
|
||||
@@ -1232,6 +1232,25 @@ streamt das Mikrofon mit demselben Protokoll wie die App
|
||||
> dieselbe Antwort gleichzeitig vorlesen. Jedes Geraet gibt darum nur aus, was
|
||||
> aus *seiner* eigenen Frage entstanden ist (`audioRequestId` → `messageId`).
|
||||
|
||||
**APK installieren** (`host_install_apk`) — ARIA kann eine APK, die unter
|
||||
`/shared/` liegt, auf das Geraet schicken und den Installationsdialog oeffnen:
|
||||
|
||||
1. Der Agent holt die Datei **stueckweise** (4 MB) per `file_request` mit
|
||||
`offset`/`length` bei der Bridge ab. Der RVS schickt jede Antwort gezielt nur
|
||||
an den Agenten — nicht an alle Geraete im Raum —, und der Fire TV muss nie
|
||||
die ganze Datei auf einmal im Speicher halten.
|
||||
2. Die Pruefsumme (sha256, vom Brain mitgegeben) wird verglichen; eine
|
||||
beschaedigte Datei wird verworfen.
|
||||
3. Android zeigt den Installationsdialog — direkt, wenn der Agent „Ueber
|
||||
anderen Apps anzeigen" darf, sonst ueber eine Benachrichtigung „Tippen zum
|
||||
Installieren".
|
||||
|
||||
> **Still installieren geht nicht.** Eine normale App darf das unter Android
|
||||
> nicht; am Geraet muss jemand „Installieren" bestaetigen. Beim ersten Mal muss
|
||||
> dort ausserdem **„Unbekannte Apps installieren"** fuer den ARIA Host-Agent
|
||||
> erlaubt werden — fehlt das, sagt der Agent es ARIA, bevor er etwas laedt.
|
||||
> Voraussetzung ist ausserdem „Steuerung erlauben" in der Agent-App.
|
||||
|
||||
### Bauen + ausrollen
|
||||
|
||||
```bash
|
||||
@@ -1267,6 +1286,65 @@ vorgeschlagen; nur wenn es keinen gibt, kommt der automatisch generierte.
|
||||
|
||||
---
|
||||
|
||||
## Ausrollen per MDM 📲 — Cockpit-App und Android-Agent
|
||||
|
||||
Beide Android-Apps lassen sich ueber ein MDM verteilen. Die Zugangsdaten gibt
|
||||
das MDM als **App-Konfiguration** (Android „Managed Configuration") mit — am
|
||||
Geraet muss niemand einen QR-Code scannen oder etwas eintippen.
|
||||
|
||||
Im MDM pro App den **Paketnamen** eintragen und darunter die Werte als
|
||||
Schluessel / Typ / Wert:
|
||||
|
||||

|
||||
|
||||
Der Typ wird pro Zeile aus *Text*, *Zahl* oder *Ja/Nein* gewaehlt:
|
||||
|
||||

|
||||
|
||||
### Cockpit-App — Paketname `com.ariacockpit`
|
||||
|
||||
| Schluessel | Typ | Wert | Pflicht |
|
||||
|------------|-----|------|---------|
|
||||
| `host` | Text | RVS-Hostname, z.B. `aria-rvs.example.de` (= `RVS_HOST`) | ja |
|
||||
| `token` | Text | Pairing-Token (= `RVS_TOKEN`, derselbe wie im QR-Code) | ja |
|
||||
| `port` | Zahl | `443` (= `RVS_PORT`) | nein, Standard 443 |
|
||||
| `tls` | Ja/Nein | Ja (= `RVS_TLS`) | nein, Standard Ja |
|
||||
|
||||
### Android-Agent — Paketname `de.hackersoft.ariaagent`
|
||||
|
||||
| Schluessel | Typ | Wert | Pflicht |
|
||||
|------------|-----|------|---------|
|
||||
| `host` | Text | RVS-Hostname (= `RVS_HOST`) | ja |
|
||||
| `token` | Text | Pairing-Token (= `RVS_TOKEN`) | ja |
|
||||
| `port` | Zahl | `443` | nein, Standard 443 |
|
||||
| `tls` | Ja/Nein | Ja | nein, Standard Ja |
|
||||
| `name` | Text | Geraetename, so erscheint er in der Diagnostic | nein, sonst der Modellname |
|
||||
| `control` | Ja/Nein | Ja = ARIA darf das Geraet steuern (tippen, wischen, Apps starten) | nein, Standard Nein |
|
||||
| `reply_mode` | Text | `overlay` (Einblendung) oder `speech` (Sprache) | nein, Standard `overlay` |
|
||||
|
||||
### Was dabei passiert
|
||||
|
||||
- **Nur mit `host` UND `token`** uebernimmt die App die Werte. Fehlt einer der
|
||||
beiden, bleibt alles wie bisher (QR-Code bzw. Eingabe am Geraet).
|
||||
- **Das MDM hat Vorrang.** Eine Aenderung im MDM (z.B. neuer Token) ueberschreibt
|
||||
die Werte am Geraet. Beim Agenten bleiben nicht gesetzte Schluessel auf ihrem
|
||||
bisherigen Wert.
|
||||
- **Wann gelesen wird:** Cockpit beim App-Start, der Agent beim App-Start und
|
||||
nach einem Neustart des Geraets. Eine Aenderung im MDM greift also erst danach.
|
||||
- **Was das MDM nicht erledigen kann:** Beim Agenten muessen die
|
||||
Bedienungshilfe (fuer `control`), die Einblendung ueber anderen Apps und die
|
||||
Bildschirm-Aufnahme weiterhin einmal am Geraet erlaubt werden — Android laesst
|
||||
diese Spezialberechtigungen nicht per App-Konfiguration zu. Cockpit fragt
|
||||
Mikrofon, Benachrichtigungen usw. wie gewohnt beim ersten Start.
|
||||
- Der **Token ist ein Zugangsschluessel**: Wer ihn kennt, landet im selben
|
||||
RVS-Room. Im MDM nur fuer Admins sichtbar ablegen.
|
||||
|
||||
Welche Schluessel es gibt, steht in `res/xml/app_restrictions.xml` der
|
||||
jeweiligen App (`android/android/app/...` bzw. `host-agent/android/app/...`);
|
||||
ein MDM, das die Liste selbst ausliest, zeigt sie dort auch mit Beschreibung an.
|
||||
|
||||
---
|
||||
|
||||
## Docker Volumes
|
||||
|
||||
| Volume / Bind | Pfad im Container | Zweck |
|
||||
|
||||
@@ -79,8 +79,8 @@ android {
|
||||
applicationId "com.ariacockpit"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 20603
|
||||
versionName "0.2.6.3"
|
||||
versionCode 20604
|
||||
versionName "0.2.6.4"
|
||||
// Fallback fuer Libraries mit Product Flavors
|
||||
missingDimensionStrategy 'react-native-camera', 'general'
|
||||
}
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
android:allowBackup="false"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:theme="@style/AppTheme">
|
||||
<!-- MDM-Ausrollen: welche Werte ein MDM mitgeben kann -->
|
||||
<meta-data
|
||||
android:name="android.content.APP_RESTRICTIONS"
|
||||
android:resource="@xml/app_restrictions" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
|
||||
@@ -27,6 +27,7 @@ class MainApplication : Application(), ReactApplication {
|
||||
add(BackgroundAudioPackage())
|
||||
add(ShareIntentPackage())
|
||||
add(TlsTrustPackage())
|
||||
add(MdmConfigPackage())
|
||||
}
|
||||
|
||||
override fun getJSMainModuleName(): String = "index"
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.ariacockpit
|
||||
|
||||
import android.content.Context
|
||||
import android.content.RestrictionsManager
|
||||
import com.facebook.react.ReactPackage
|
||||
import com.facebook.react.bridge.Arguments
|
||||
import com.facebook.react.bridge.NativeModule
|
||||
import com.facebook.react.bridge.Promise
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
||||
import com.facebook.react.bridge.ReactMethod
|
||||
import com.facebook.react.uimanager.ViewManager
|
||||
|
||||
/**
|
||||
* Verbindungsdaten aus dem MDM ("Managed Configuration" / App-Restrictions).
|
||||
*
|
||||
* Das MDM schreibt Schluessel/Werte fuer com.ariacockpit; welche es gibt,
|
||||
* steht in res/xml/app_restrictions.xml. Die App liest sie beim Start —
|
||||
* so muss beim Ausrollen niemand einen QR-Code scannen.
|
||||
*
|
||||
* Gibt nur die Schluessel zurueck, die das MDM wirklich gesetzt hat.
|
||||
*/
|
||||
class MdmConfigModule(ctx: ReactApplicationContext) : ReactContextBaseJavaModule(ctx) {
|
||||
override fun getName() = "MdmConfig"
|
||||
|
||||
@ReactMethod
|
||||
fun getConfig(promise: Promise) {
|
||||
try {
|
||||
val rm = reactApplicationContext.getSystemService(Context.RESTRICTIONS_SERVICE) as RestrictionsManager
|
||||
val b = rm.applicationRestrictions
|
||||
val out = Arguments.createMap()
|
||||
for (key in b.keySet()) {
|
||||
when (val v = b.get(key)) {
|
||||
is String -> out.putString(key, v)
|
||||
is Int -> out.putInt(key, v)
|
||||
is Boolean -> out.putBoolean(key, v)
|
||||
}
|
||||
}
|
||||
promise.resolve(out)
|
||||
} catch (e: Exception) {
|
||||
promise.resolve(Arguments.createMap())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MdmConfigPackage : ReactPackage {
|
||||
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
|
||||
listOf(MdmConfigModule(reactContext))
|
||||
|
||||
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
|
||||
emptyList()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Texte fuer die MDM-Werte (res/xml/app_restrictions.xml) -->
|
||||
<resources>
|
||||
<string name="mdm_host_title" translatable="false">RVS-Host</string>
|
||||
<string name="mdm_host_description" translatable="false">Hostname des RVS, z.B. aria-rvs.example.de</string>
|
||||
<string name="mdm_port_title" translatable="false">RVS-Port</string>
|
||||
<string name="mdm_tls_title" translatable="false">TLS verwenden</string>
|
||||
<string name="mdm_token_title" translatable="false">Token</string>
|
||||
<string name="mdm_token_description" translatable="false">Derselbe Token wie im QR-Code</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Werte, die ein MDM beim Ausrollen mitgeben kann (Managed Configuration).
|
||||
Sind host UND token gesetzt, verbindet sich die App damit — ohne QR-Code. -->
|
||||
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<restriction
|
||||
android:key="host"
|
||||
android:title="@string/mdm_host_title"
|
||||
android:description="@string/mdm_host_description"
|
||||
android:restrictionType="string" />
|
||||
<restriction
|
||||
android:key="port"
|
||||
android:title="@string/mdm_port_title"
|
||||
android:defaultValue="443"
|
||||
android:restrictionType="integer" />
|
||||
<restriction
|
||||
android:key="tls"
|
||||
android:title="@string/mdm_tls_title"
|
||||
android:defaultValue="true"
|
||||
android:restrictionType="bool" />
|
||||
<restriction
|
||||
android:key="token"
|
||||
android:title="@string/mdm_token_title"
|
||||
android:description="@string/mdm_token_description"
|
||||
android:restrictionType="string" />
|
||||
</restrictions>
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aria-cockpit",
|
||||
"version": "0.2.6.3",
|
||||
"version": "0.2.6.4",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"android": "react-native run-android",
|
||||
|
||||
@@ -93,6 +93,7 @@ import MemoryBrowser from '../components/MemoryBrowser';
|
||||
import TriggerBrowser from '../components/TriggerBrowser';
|
||||
import SkillBrowser from '../components/SkillBrowser';
|
||||
import OAuthBrowser from '../components/OAuthBrowser';
|
||||
import ClaudeLogin from '../components/ClaudeLogin';
|
||||
import VoiceIdEnrollment from '../components/VoiceIdEnrollment';
|
||||
import ProjectsBrowser from '../components/ProjectsBrowser';
|
||||
import brainApi from '../services/brainApi';
|
||||
@@ -159,6 +160,7 @@ const SETTINGS_SECTIONS = [
|
||||
{ id: 'triggers', icon: '⏰', label: 'Trigger', desc: 'Timer + Watcher anlegen, bearbeiten, löschen' },
|
||||
{ id: 'skills', icon: '🛠️', label: 'Skills', desc: 'Skills ausführen, aktivieren, Logs ansehen, löschen' },
|
||||
{ id: 'oauth', icon: '🔑', label: 'OAuth-Apps', desc: 'Spotify, Dropbox, ... — client_id/secret, autorisieren, abmelden' },
|
||||
{ id: 'claude', icon: '🤖', label: 'Claude-Anmeldung', desc: 'ARIA neu bei Claude anmelden, wenn die Anmeldung abgelaufen ist' },
|
||||
{ id: 'protocol', icon: '📜', label: 'Protokoll', desc: 'Privatsphaere, Backup' },
|
||||
{ id: 'about', icon: 'ℹ️', label: 'Ueber', desc: 'App-Version, Update' },
|
||||
] as const;
|
||||
@@ -2399,6 +2401,12 @@ const SettingsScreen: React.FC = () => {
|
||||
</View>
|
||||
</>)}
|
||||
|
||||
{/* === Claude-Anmeldung === */}
|
||||
{currentSection === 'claude' && (<>
|
||||
<Text style={styles.sectionTitle}>Claude-Anmeldung</Text>
|
||||
<ClaudeLogin />
|
||||
</>)}
|
||||
|
||||
{/* === Logs === */}
|
||||
{currentSection === 'protocol' && (<>
|
||||
<Text style={styles.sectionTitle}>Protokoll</Text>
|
||||
|
||||
@@ -491,7 +491,40 @@ class RVSConnection {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verbindungsdaten aus dem MDM (Managed Configuration), falls beim Ausrollen
|
||||
* gesetzt. Nur gueltig mit host UND token. Schluessel: res/xml/app_restrictions.xml
|
||||
*/
|
||||
async loadMdmConfig(): Promise<ConnectionConfig | null> {
|
||||
try {
|
||||
const Mdm: any = NativeModules.MdmConfig;
|
||||
if (Platform.OS !== 'android' || !Mdm?.getConfig) return null;
|
||||
const m = await Mdm.getConfig();
|
||||
const host = String(m?.host ?? '').trim();
|
||||
const token = String(m?.token ?? '').trim();
|
||||
if (!host || !token) return null;
|
||||
const port = Number(m.port);
|
||||
return {
|
||||
host,
|
||||
token,
|
||||
port: Number.isFinite(port) && port > 0 ? port : 443,
|
||||
useTLS: m.tls !== false,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async loadConfig(): Promise<ConnectionConfig | null> {
|
||||
// Vom MDM gesetzte Werte haben Vorrang: so kommen geaenderte Zugangsdaten
|
||||
// beim naechsten App-Start an, ohne dass jemand am Geraet etwas tun muss.
|
||||
const mdm = await this.loadMdmConfig();
|
||||
if (mdm) {
|
||||
console.log('[RVS] Konfiguration aus dem MDM');
|
||||
this.config = mdm;
|
||||
await this.saveConfig(mdm);
|
||||
return mdm;
|
||||
}
|
||||
try {
|
||||
const data = await AsyncStorage.getItem(RVSConnection.STORAGE_KEY);
|
||||
if (data) {
|
||||
|
||||
+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()
|
||||
|
||||
@@ -3315,6 +3315,43 @@ class ARIABridge:
|
||||
"timestamp": int(asyncio.get_event_loop().time() * 1000),
|
||||
})
|
||||
return
|
||||
# Stueckweiser Abruf (z.B. Android-Agent holt eine APK): mit
|
||||
# "offset" kommt nur ein Teil zurueck. So muss niemand eine grosse
|
||||
# Datei am Stueck in den Speicher nehmen (Fire TV hat wenig RAM).
|
||||
if "offset" in payload:
|
||||
CHUNK_MAX = 8 * 1024 * 1024
|
||||
try:
|
||||
offset = max(0, int(payload.get("offset") or 0))
|
||||
length = int(payload.get("length") or CHUNK_MAX)
|
||||
except (TypeError, ValueError):
|
||||
offset, length = 0, CHUNK_MAX
|
||||
length = max(1, min(length, CHUNK_MAX))
|
||||
try:
|
||||
total = os.path.getsize(server_path)
|
||||
with open(server_path, "rb") as f:
|
||||
f.seek(offset)
|
||||
chunk = f.read(length)
|
||||
except OSError as exc:
|
||||
await self._send_to_rvs({
|
||||
"type": "file_response",
|
||||
"payload": {"requestId": req_id, "error": f"Lesen fehlgeschlagen: {exc}"},
|
||||
"timestamp": int(asyncio.get_event_loop().time() * 1000),
|
||||
})
|
||||
return
|
||||
await self._send_to_rvs({
|
||||
"type": "file_response",
|
||||
"payload": {
|
||||
"requestId": req_id,
|
||||
"serverPath": server_path,
|
||||
"name": os.path.basename(server_path),
|
||||
"offset": offset,
|
||||
"sizeBytes": total,
|
||||
"eof": offset + len(chunk) >= total,
|
||||
"base64": base64.b64encode(chunk).decode("ascii"),
|
||||
},
|
||||
"timestamp": int(asyncio.get_event_loop().time() * 1000),
|
||||
})
|
||||
return
|
||||
# Groessen-Check VOR base64-Encode + Send. Sonst zerreisst's bei
|
||||
# grossen Files (>~70 MB binaer) die WebSocket-Verbindung mit
|
||||
# Code 1009 (message too big) — RVS-Server droppt, Bridge crasht
|
||||
|
||||
+52
-22
@@ -422,6 +422,23 @@
|
||||
<button class="main-nav-btn" onclick="switchMainTab('settings')">Einstellungen</button>
|
||||
</div>
|
||||
|
||||
<!-- Neues-Projekt Modal (Body-Ebene, damit es ueber jedem Tab erscheint) -->
|
||||
<div id="project-create-modal" style="display:none;position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:1000;align-items:center;justify-content:center;">
|
||||
<div style="background:#15151E;padding:20px;border-radius:8px;min-width:340px;max-width:90vw;">
|
||||
<h3 style="margin-top:0;color:#E0E0F0;">Neues Projekt</h3>
|
||||
<label style="display:block;color:#8888AA;font-size:12px;margin-bottom:4px;">Name</label>
|
||||
<input type="text" id="project-create-name" placeholder="z.B. Frankreich-Urlaub"
|
||||
style="width:100%;box-sizing:border-box;background:#0A0A14;color:#E0E0F0;border:1px solid #2A2A3E;padding:8px;border-radius:4px;font-size:14px;margin-bottom:10px;">
|
||||
<label style="display:block;color:#8888AA;font-size:12px;margin-bottom:4px;">Beschreibung (optional)</label>
|
||||
<textarea id="project-create-desc" placeholder="1 Satz worum's geht. Hilft beim Wiederfinden."
|
||||
style="width:100%;box-sizing:border-box;background:#0A0A14;color:#E0E0F0;border:1px solid #2A2A3E;padding:8px;border-radius:4px;font-size:13px;height:60px;resize:vertical;margin-bottom:14px;"></textarea>
|
||||
<div style="display:flex;gap:8px;justify-content:flex-end;">
|
||||
<button class="btn secondary" onclick="closeCreateProjectModal()" style="padding:6px 14px;font-size:12px;">Abbrechen</button>
|
||||
<button class="btn primary" onclick="submitCreateProject()" style="padding:6px 14px;font-size:12px;">Anlegen + aktivieren</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ══════ TAB: Main ══════ -->
|
||||
<div id="tab-main" class="main-tab visible">
|
||||
|
||||
@@ -1720,22 +1737,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Neues-Projekt Modal -->
|
||||
<div id="project-create-modal" style="display:none;position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:1000;align-items:center;justify-content:center;">
|
||||
<div style="background:#15151E;padding:20px;border-radius:8px;min-width:340px;max-width:90vw;">
|
||||
<h3 style="margin-top:0;color:#E0E0F0;">Neues Projekt</h3>
|
||||
<label style="display:block;color:#8888AA;font-size:12px;margin-bottom:4px;">Name</label>
|
||||
<input type="text" id="project-create-name" placeholder="z.B. Frankreich-Urlaub"
|
||||
style="width:100%;box-sizing:border-box;background:#0A0A14;color:#E0E0F0;border:1px solid #2A2A3E;padding:8px;border-radius:4px;font-size:14px;margin-bottom:10px;">
|
||||
<label style="display:block;color:#8888AA;font-size:12px;margin-bottom:4px;">Beschreibung (optional)</label>
|
||||
<textarea id="project-create-desc" placeholder="1 Satz worum's geht. Hilft beim Wiederfinden."
|
||||
style="width:100%;box-sizing:border-box;background:#0A0A14;color:#E0E0F0;border:1px solid #2A2A3E;padding:8px;border-radius:4px;font-size:13px;height:60px;resize:vertical;margin-bottom:14px;"></textarea>
|
||||
<div style="display:flex;gap:8px;justify-content:flex-end;">
|
||||
<button class="btn secondary" onclick="closeCreateProjectModal()" style="padding:6px 14px;font-size:12px;">Abbrechen</button>
|
||||
<button class="btn primary" onclick="submitCreateProject()" style="padding:6px 14px;font-size:12px;">Anlegen + aktivieren</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Neues-Projekt Modal: liegt bewusst NICHT hier, sondern auf Body-Ebene
|
||||
(vor #tab-main). Lag es in #tab-brain, blieb es unsichtbar, sobald man
|
||||
den Button vom Hauptchat-Tab aus klickte (tab-brain = display:none). -->
|
||||
|
||||
<div class="settings-section">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;">
|
||||
@@ -5585,12 +5589,14 @@
|
||||
// die echte steht im worker.gpus).
|
||||
const _cardLoadStreams = new Map(); // instanceId → {node, gpus, single}
|
||||
const _cardLoad = new Map(); // node|uuid → {node, index, name, util, ..., hist: []}
|
||||
const _nodeRam = new Map(); // node → {ramUsed, ramTotal, ts} (System-RAM der Box)
|
||||
let _cardLoadTimer = null;
|
||||
/** onlyNode: nur diese Box (Button in der Compute-Flotte); leer = alle */
|
||||
function openCardLoad(onlyNode) {
|
||||
document.getElementById('card-load-modal').style.display = 'flex';
|
||||
document.getElementById('card-load-scope').textContent = onlyNode ? ' · ' + onlyNode : '';
|
||||
_cardLoad.clear();
|
||||
_nodeRam.clear();
|
||||
_cardLoadStreams.clear();
|
||||
const byNode = {};
|
||||
for (const w of workers) {
|
||||
@@ -5621,7 +5627,9 @@
|
||||
}
|
||||
function onCardLoadStats(p) {
|
||||
const src = _cardLoadStreams.get(p.instanceId);
|
||||
if (!src || !Array.isArray(p.cards)) return;
|
||||
if (!src) return;
|
||||
if (p.ram && (p.ram.ramTotal || p.ram.ramUsed)) _nodeRam.set(src.node, { ...p.ram, ts: Date.now() });
|
||||
if (!Array.isArray(p.cards)) { renderCardLoad(); return; }
|
||||
for (const c of p.cards) {
|
||||
// Einzel-Dienst: Container-Nummer (0) durch die echte Karte ersetzen
|
||||
const index = src.single && src.gpus && !src.gpus.includes(',') ? src.gpus : c.index;
|
||||
@@ -5679,8 +5687,22 @@
|
||||
'<div style="margin-top:6px;font-size:12px;color:#C8C8D8;">' + (jobs.length ? jobs.map(escapeHtml).join(' · ') : '<span style="color:#555570;">nichts zugewiesen</span>') + '</div>' +
|
||||
'</div>';
|
||||
}).join('') : '<div style="color:#8888AA;font-size:12px;">warte auf Werte … (Box mit altem Stand? Dann liefert sie noch keine Werte pro Karte.)</div>';
|
||||
const ram = _nodeRam.get(node);
|
||||
let ramRow = '';
|
||||
if (ram && ram.ramTotal) {
|
||||
const ramPct = ram.ramUsed / ram.ramTotal * 100;
|
||||
const ramColor = ramPct >= 92 ? '#FF6B6B' : ramPct >= 80 ? '#FFB020' : '#B392F0';
|
||||
ramRow = '<div style="border:1px solid #1E1E2E;border-radius:8px;padding:8px 12px;background:#12122A;margin-bottom:8px;">' +
|
||||
'<div style="display:grid;grid-template-columns:150px 1fr 150px;gap:6px 10px;align-items:center;font-size:12px;">' +
|
||||
'<span style="color:#8888AA;">Arbeitsspeicher (RAM)</span>' + _bar(ramPct, ramColor) +
|
||||
'<span style="color:#E0E0F0;">' + (ram.ramUsed / 1024).toFixed(1) + ' / ' + (ram.ramTotal / 1024).toFixed(0) + ' GB</span>' +
|
||||
'</div>' +
|
||||
'<div style="margin-top:4px;font-size:11px;color:#555570;">inkl. in den RAM ausgelagerter MoE-Experten</div>' +
|
||||
'</div>';
|
||||
}
|
||||
return '<div><div style="color:#E0E0F0;font-weight:700;margin-bottom:6px;">🖥 ' + escapeHtml(node) +
|
||||
(stale ? ' <span style="color:#FF9F0A;font-size:11px;font-weight:normal;">· keine neuen Werte</span>' : '') + '</div>' +
|
||||
ramRow +
|
||||
'<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:10px;">' + inner + '</div></div>';
|
||||
}).join('');
|
||||
}
|
||||
@@ -10993,7 +11015,7 @@
|
||||
cpuMoe = sl.cpuMoe > 0 ? -2 : (sl.cpuMoe || 0); // teilweise aufgeteilt → fuer den neuen Kontext neu rechnen
|
||||
} else {
|
||||
const vramGB = sl.vramMB ? sl.vramMB / 1024 : 0;
|
||||
cpuMoe = await askCpuMoe(m, sl.vramMB || 0);
|
||||
cpuMoe = await askCpuMoe(m, sl.vramMB || 0, onlineLlmBoxes().find(b => b.instanceId === target));
|
||||
if (cpuMoe === null) return;
|
||||
const warn = (!cpuMoe && vramGB && m.sizeGB && m.sizeGB > vramGB * 0.92)
|
||||
? `\n\n⚠ ${m.id} ist etwa ${m.sizeGB} GB groß, die Karte hat ${vramGB.toFixed(0)} GB — wahrscheinlich passt es nicht.` : '';
|
||||
@@ -11070,12 +11092,20 @@
|
||||
// "Experten" duerfen darum in den Arbeitsspeicher, ohne dass es unbrauchbar
|
||||
// langsam wird. Erkennung am Namen (A3B, A4B, MoE …); sicher weiss es die Box
|
||||
// erst nach dem Laden (slot.moe).
|
||||
function looksMoe(m) { return /(\bA\d+(\.\d+)?B\b|moe|mixtral)/i.test((m.id || '') + ' ' + (m.hfRepo || '')); }
|
||||
// MoE? Am Namen erkennbar (A3B, moe, mixtral) — ODER die Box weiss es schon,
|
||||
// weil die Datei dort liegt (Profil aus der GGUF). Nur am Namen zu raten hat
|
||||
// z.B. Imperum-CybersecurityLLM (Qwen3.6-35B-A3B) verpasst: keine Rueckfrage,
|
||||
// alles auf die Karte, Laden scheitert.
|
||||
function looksMoe(m, box) {
|
||||
if (/(\bA\d+(\.\d+)?B\b|moe|mixtral)/i.test((m.id || '') + ' ' + (m.hfRepo || ''))) return true;
|
||||
if (Array.isArray(m.tags) && m.tags.some(t => String(t).toLowerCase() === 'moe')) return true;
|
||||
return !!(box && _ctxChoices(m.id, box, null).moe);
|
||||
}
|
||||
/** Promise: 0 = normal laden, -2 = Experten automatisch aufteilen, null = abbrechen.
|
||||
* Eigener Dialog mit drei Knoepfen — bei confirm() hiess "Abbrechen" frueher
|
||||
* "normal laden", und das liest jeder als "gar nicht laden". */
|
||||
function askCpuMoe(m, vramMB) {
|
||||
if (!looksMoe(m) || !vramMB || !m.sizeGB || m.sizeGB * 1024 <= vramMB * 0.85) return Promise.resolve(0);
|
||||
function askCpuMoe(m, vramMB, box) {
|
||||
if (!looksMoe(m, box) || !vramMB || !m.sizeGB || m.sizeGB * 1024 <= vramMB * 0.85) return Promise.resolve(0);
|
||||
return new Promise(resolve => {
|
||||
const bg = document.createElement('div');
|
||||
bg.style.cssText = 'position:fixed;inset:0;z-index:10000;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;padding:16px;';
|
||||
@@ -11158,7 +11188,7 @@
|
||||
!await uiConfirm(`Karte ${gpu} auf ${tgt.box.node} hält gerade ${tgt.slot.model}.\n\n`
|
||||
+ `${m.id} ersetzt es. Clients, die ${tgt.slot.model} nutzen, verlieren es dann.\n`
|
||||
+ `Die anderen Karten dieser Box starten dabei kurz neu.\n\nErsetzen?`)) return;
|
||||
const cpuMoe = await askCpuMoe(m, (tgt && tgt.slot && tgt.slot.vramMB) || 0);
|
||||
const cpuMoe = await askCpuMoe(m, (tgt && tgt.slot && tgt.slot.vramMB) || 0, tgt && tgt.box);
|
||||
if (cpuMoe === null) return;
|
||||
const st = document.getElementById('llm-catalog-status');
|
||||
const ctxSel = document.getElementById('llm-cat-ctx-' + i);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
@@ -11,8 +11,8 @@ android {
|
||||
applicationId 'de.hackersoft.ariaagent'
|
||||
minSdk 26
|
||||
targetSdk 33 // 33 vermeidet die Foreground-Service-Typ-Pflicht von 34
|
||||
versionCode 108
|
||||
versionName '0.0.1.8'
|
||||
versionCode 200
|
||||
versionName '0.0.2.0'
|
||||
}
|
||||
|
||||
// Fester Signaturschlüssel: jeder Build signiert mit DEMSELBEN Key, damit
|
||||
|
||||
@@ -37,6 +37,11 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AppCompat.DayNight">
|
||||
|
||||
<!-- MDM-Ausrollen: welche Werte ein MDM mitgeben kann -->
|
||||
<meta-data
|
||||
android:name="android.content.APP_RESTRICTIONS"
|
||||
android:resource="@xml/app_restrictions" />
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package de.hackersoft.ariaagent
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.content.FileProvider
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
import java.security.MessageDigest
|
||||
|
||||
/**
|
||||
* APK von ARIA empfangen und installieren (host_command "apk_install").
|
||||
*
|
||||
* 1. Die APK liegt bei ARIA unter /shared/. Wir holen sie STUECKWEISE per
|
||||
* file_request (offset/length) — der RVS schickt die Antwort gezielt nur
|
||||
* an uns, nicht an alle Geraete im Raum, und der Fire TV muss nie die
|
||||
* ganze Datei auf einmal im Speicher halten.
|
||||
* 2. Pruefsumme (sha256) vergleichen.
|
||||
* 3. Installationsdialog von Android oeffnen. Still installieren darf eine
|
||||
* normale App nicht — am Geraet muss jemand bestaetigen.
|
||||
*/
|
||||
object ApkReceiver {
|
||||
private const val DIR = "incoming"
|
||||
private const val CHUNK = 4 * 1024 * 1024
|
||||
private const val CH = "aria_agent_install"
|
||||
private const val NOTIF_ID = 4712
|
||||
|
||||
/** Holt ein Stueck: (path, offset, length) -> file_response-Payload oder null (Timeout). */
|
||||
fun interface ChunkFetcher {
|
||||
fun fetch(path: String, offset: Long, length: Int): JSONObject?
|
||||
}
|
||||
|
||||
fun run(ctx: Context, params: JSONObject, fetcher: ChunkFetcher): JSONObject {
|
||||
val path = params.optString("path")
|
||||
val size = params.optLong("size", -1)
|
||||
val sha = params.optString("sha256").lowercase()
|
||||
val name = params.optString("name").ifBlank { File(path).name }
|
||||
if (!path.startsWith("/shared/") || !path.lowercase().endsWith(".apk"))
|
||||
return err("path muss eine .apk unter /shared/ sein")
|
||||
if (size <= 0) return err("Groesse fehlt")
|
||||
|
||||
// Ohne diese Erlaubnis oeffnet Android den Dialog gar nicht — lieber
|
||||
// VOR dem Download sagen, statt Megabytes umsonst zu holen.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !ctx.packageManager.canRequestPackageInstalls()) {
|
||||
openUnknownSourcesSettings(ctx)
|
||||
return err("Auf dem Geraet ist 'Unbekannte Apps installieren' fuer den ARIA Host-Agent " +
|
||||
"nicht erlaubt. Die Einstellung ist jetzt dort geoeffnet (falls die App im " +
|
||||
"Vordergrund ist) — einmal erlauben, dann nochmal versuchen.")
|
||||
}
|
||||
|
||||
val dir = File(ctx.cacheDir, DIR).apply { mkdirs() }
|
||||
dir.listFiles()?.forEach { it.delete() } // Reste frueherer Uebertragungen
|
||||
if (dir.usableSpace < size + 20L * 1024 * 1024)
|
||||
return err("Zu wenig Speicher auf dem Geraet (${size / 1048576} MB noetig, " +
|
||||
"${dir.usableSpace / 1048576} MB frei)")
|
||||
|
||||
val safe = name.replace(Regex("[^A-Za-z0-9._-]+"), "_")
|
||||
val file = File(dir, safe)
|
||||
val md = MessageDigest.getInstance("SHA-256")
|
||||
file.outputStream().use { out ->
|
||||
var offset = 0L
|
||||
while (offset < size) {
|
||||
var chunk: JSONObject? = null
|
||||
for (attempt in 1..3) {
|
||||
chunk = fetcher.fetch(path, offset, CHUNK)
|
||||
if (chunk != null) break
|
||||
}
|
||||
if (chunk == null) return err("Keine Antwort beim Abholen (bei ${offset / 1048576} MB)")
|
||||
if (chunk.has("error")) return err("Abholen fehlgeschlagen: ${chunk.optString("error")}")
|
||||
if (!chunk.has("offset"))
|
||||
return err("Die Bridge kennt den stueckweisen Abruf noch nicht — Bridge neu deployen.")
|
||||
val bytes = android.util.Base64.decode(chunk.optString("base64"), android.util.Base64.DEFAULT)
|
||||
if (bytes.isEmpty()) return err("Leeres Stueck bei ${offset / 1048576} MB")
|
||||
out.write(bytes)
|
||||
md.update(bytes)
|
||||
offset += bytes.size
|
||||
if (chunk.optBoolean("eof")) break
|
||||
}
|
||||
}
|
||||
if (file.length() != size) {
|
||||
file.delete()
|
||||
return err("Unvollstaendig: ${file.length()} von $size Bytes")
|
||||
}
|
||||
val got = md.digest().joinToString("") { "%02x".format(it) }
|
||||
if (sha.isNotEmpty() && got != sha) {
|
||||
file.delete()
|
||||
return err("Pruefsumme stimmt nicht — Datei beschaedigt, nicht installiert")
|
||||
}
|
||||
|
||||
val info = try { ctx.packageManager.getPackageArchiveInfo(file.path, 0) } catch (_: Exception) { null }
|
||||
?: run { file.delete(); return err("Die Datei ist keine gueltige APK") }
|
||||
val label = "${info.packageName} ${info.versionName ?: ""}".trim()
|
||||
|
||||
val shown = openInstaller(ctx, file, label)
|
||||
val msg = if (shown)
|
||||
"APK $name ($label) uebertragen — der Installationsdialog ist auf dem Geraet offen " +
|
||||
"und muss dort bestaetigt werden."
|
||||
else
|
||||
"APK $name ($label) uebertragen — auf dem Geraet liegt eine Benachrichtigung " +
|
||||
"'Tippen zum Installieren'. Jemand muss sie antippen und bestaetigen."
|
||||
return JSONObject().put("ok", true).put("result", JSONObject()
|
||||
.put("message", msg).put("package", info.packageName)
|
||||
.put("version", info.versionName ?: "").put("bytes", size))
|
||||
}
|
||||
|
||||
/** Dialog direkt oeffnen, wenn Android das aus dem Hintergrund erlaubt; immer
|
||||
* auch eine Benachrichtigung als Rueckfallweg. true = Dialog direkt geoeffnet. */
|
||||
private fun openInstaller(ctx: Context, file: File, label: String): Boolean {
|
||||
val uri = FileProvider.getUriForFile(ctx, "${ctx.packageName}.fileprovider", file)
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
.setDataAndType(uri, "application/vnd.android.package-archive")
|
||||
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
|
||||
val nm = ctx.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
nm.createNotificationChannel(NotificationChannel(CH, "Installationen von ARIA",
|
||||
NotificationManager.IMPORTANCE_HIGH))
|
||||
}
|
||||
val pi = PendingIntent.getActivity(ctx, 2, intent,
|
||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
nm.notify(NOTIF_ID, NotificationCompat.Builder(ctx, CH)
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download_done)
|
||||
.setContentTitle("ARIA moechte eine App installieren")
|
||||
.setContentText("$label — tippen zum Installieren")
|
||||
.setContentIntent(pi)
|
||||
.setAutoCancel(true)
|
||||
.build())
|
||||
|
||||
// Aus dem Hintergrund duerfen Apps nur mit "Ueber anderen Apps anzeigen"
|
||||
// eine Activity starten — die hat der Agent meist (Einblendungen).
|
||||
if (!OverlayView.canDraw(ctx)) return false
|
||||
return try { ctx.startActivity(intent); true } catch (_: Exception) { false }
|
||||
}
|
||||
|
||||
private fun openUnknownSourcesSettings(ctx: Context) {
|
||||
try {
|
||||
ctx.startActivity(Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES,
|
||||
Uri.parse("package:${ctx.packageName}")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||
} catch (_: Exception) {}
|
||||
}
|
||||
|
||||
private fun err(m: String) = JSONObject().put("ok", false).put("error", m)
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import android.content.Intent
|
||||
class BootReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(ctx: Context, intent: Intent) {
|
||||
if (intent.action == Intent.ACTION_BOOT_COMPLETED) {
|
||||
MdmConfig.apply(ctx) // vom MDM geaenderte Werte uebernehmen
|
||||
if (AgentConfig.load(ctx).isValid()) {
|
||||
AgentService.start(ctx)
|
||||
}
|
||||
|
||||
@@ -134,7 +134,15 @@ class MainActivity : AppCompatActivity() {
|
||||
// Fern-Einrichtung (z.B. Fire TV, wo QR-Scan und Tippen wegfallen): der
|
||||
// Satellit startet die App per ADB mit den Zugangsdaten als Extras.
|
||||
// Hat das geklappt, ist die UI schon befuellt — sonst normal laden.
|
||||
if (!applyProvisioning(intent)) loadIntoUi(AgentConfig.load(this))
|
||||
if (!applyProvisioning(intent)) {
|
||||
// Per MDM ausgerollt? Dann Werte uebernehmen und gleich verbinden.
|
||||
val mdm = MdmConfig.apply(this)
|
||||
if (mdm != null) {
|
||||
AgentService.start(this)
|
||||
toast("Vom MDM eingerichtet: ${mdm.host} — Agent gestartet")
|
||||
}
|
||||
loadIntoUi(mdm ?: AgentConfig.load(this))
|
||||
}
|
||||
|
||||
// Fire TV: kein Touchscreen — der QR-Scan ist dort sinnlos (keine Kamera),
|
||||
// und der erste Fokus muss gesetzt sein, damit die Fernbedienung greift.
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package de.hackersoft.ariaagent
|
||||
|
||||
import android.content.Context
|
||||
import android.content.RestrictionsManager
|
||||
|
||||
/**
|
||||
* Einrichtung per MDM ("Managed Configuration" / App-Restrictions).
|
||||
*
|
||||
* Das MDM schreibt Schluessel/Werte fuer de.hackersoft.ariaagent; welche es
|
||||
* gibt, steht in res/xml/app_restrictions.xml. Sind host UND token gesetzt,
|
||||
* uebernimmt der Agent sie — vom MDM gesetzte Werte haben Vorrang vor der
|
||||
* Eingabe am Geraet, nicht gesetzte Schluessel lassen den alten Wert stehen.
|
||||
*
|
||||
* Gelesen wird beim App-Start und nach dem Booten.
|
||||
*/
|
||||
object MdmConfig {
|
||||
|
||||
/** Gibt die neue Konfiguration zurueck, wenn das MDM etwas geaendert hat, sonst null. */
|
||||
fun apply(ctx: Context): AgentConfig? {
|
||||
val b = try {
|
||||
(ctx.getSystemService(Context.RESTRICTIONS_SERVICE) as RestrictionsManager)
|
||||
.applicationRestrictions
|
||||
} catch (_: Exception) { return null }
|
||||
|
||||
val host = b.getString("host")?.trim().orEmpty()
|
||||
val token = b.getString("token")?.trim().orEmpty()
|
||||
if (host.isEmpty() || token.isEmpty()) return null
|
||||
|
||||
val old = AgentConfig.load(ctx)
|
||||
val cfg = old.copy(
|
||||
host = host,
|
||||
token = token,
|
||||
port = if (b.containsKey("port")) b.getInt("port").takeIf { it > 0 } ?: 443 else old.port,
|
||||
tls = if (b.containsKey("tls")) b.getBoolean("tls") else old.tls,
|
||||
name = b.getString("name")?.trim().takeUnless { it.isNullOrEmpty() } ?: old.name,
|
||||
controlEnabled = if (b.containsKey("control")) b.getBoolean("control") else old.controlEnabled,
|
||||
replyMode = b.getString("reply_mode")?.trim()
|
||||
?.takeIf { it == "overlay" || it == "speech" } ?: old.replyMode,
|
||||
)
|
||||
if (cfg == old) return null
|
||||
cfg.save(ctx)
|
||||
return cfg
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import okhttp3.WebSocket
|
||||
import okhttp3.WebSocketListener
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.LinkedBlockingQueue
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
@@ -57,7 +59,9 @@ class RvsClient(
|
||||
// Ausgabe auf dem Geraet: Einblendung ueber dem Bild + Sprachausgabe.
|
||||
"notify", "speak", "volume",
|
||||
// Sprachdialog: Mikro oeffnen/schliessen (ARIA kann es auch anstossen).
|
||||
"listen", "listen_stop")
|
||||
"listen", "listen_stop",
|
||||
// APK von ARIA empfangen + Installationsdialog oeffnen.
|
||||
"apk_install")
|
||||
if (isTv) base += "tv" // Kennzeichen: dieses Geraet ist ein Fernseher/Stick
|
||||
base
|
||||
}
|
||||
@@ -189,6 +193,13 @@ class RvsClient(
|
||||
AgentUpdater.onAvailable(appCtx, config, p.optString("version"), p.optLong("size"))
|
||||
return
|
||||
}
|
||||
// Antwort auf einen eigenen file_request (APK-Abruf)? Dann an den
|
||||
// wartenden Thread weiterreichen — sonst niemanden interessiert.
|
||||
if (type == "file_response") {
|
||||
val p = msg.optJSONObject("payload") ?: return
|
||||
fileWaiters[p.optString("requestId")]?.offer(p)
|
||||
return
|
||||
}
|
||||
if (type != "host_command") {
|
||||
if (type in VOICE_TYPES) {
|
||||
try { voice.handle(type, msg.optJSONObject("payload") ?: JSONObject()) }
|
||||
@@ -230,6 +241,26 @@ class RvsClient(
|
||||
return
|
||||
}
|
||||
|
||||
// APK holen dauert (viele Stuecke): eigener Thread, denn die Antworten
|
||||
// kommen ueber genau diesen Lese-Thread herein.
|
||||
if (action == "apk_install") {
|
||||
if (!config.controlEnabled) {
|
||||
reply(err("Steuerung ist in der Agent-App deaktiviert (Schalter 'Steuerung erlauben')."))
|
||||
return
|
||||
}
|
||||
Thread {
|
||||
val r = try {
|
||||
ApkReceiver.run(appCtx, params) { path, offset, length ->
|
||||
fetchChunk(webSocket, path, offset, length)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
err("Fehler bei '$action': ${t.javaClass.simpleName}: ${t.message}")
|
||||
}
|
||||
reply(r)
|
||||
}.also { it.isDaemon = true }.start()
|
||||
return
|
||||
}
|
||||
|
||||
// WICHTIG: JEDE Aktion muss ein host_result liefern — auch bei Exception
|
||||
// ODER OutOfMemoryError (Throwable!). Sonst bekommt ARIA statt einer
|
||||
// Fehlermeldung nur einen Timeout (kein Result kommt zurueck).
|
||||
@@ -265,6 +296,25 @@ class RvsClient(
|
||||
reply(result)
|
||||
}
|
||||
|
||||
/** Wartende file_request-Abrufe: requestId -> Briefkasten fuer die Antwort. */
|
||||
private val fileWaiters = ConcurrentHashMap<String, LinkedBlockingQueue<JSONObject>>()
|
||||
|
||||
/** Ein Stueck einer Datei unter /shared/ bei der Bridge abholen (null = Timeout). */
|
||||
private fun fetchChunk(webSocket: WebSocket, path: String, offset: Long, length: Int): JSONObject? {
|
||||
val rid = "apk-" + java.util.UUID.randomUUID().toString()
|
||||
val box = LinkedBlockingQueue<JSONObject>(1)
|
||||
fileWaiters[rid] = box
|
||||
try {
|
||||
val sent = send(webSocket, "file_request", JSONObject()
|
||||
.put("requestId", rid).put("serverPath", path)
|
||||
.put("offset", offset).put("length", length))
|
||||
if (!sent) return null
|
||||
return box.poll(60, TimeUnit.SECONDS)
|
||||
} finally {
|
||||
fileWaiters.remove(rid)
|
||||
}
|
||||
}
|
||||
|
||||
/** Steuer-Aktionen, die ein entsperrtes Gerät brauchen. */
|
||||
private val CONTROL_ACTIONS = setOf("ui_tap", "ui_text", "ui_swipe", "ui_key", "app_launch")
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Texte fuer die MDM-Werte (res/xml/app_restrictions.xml) -->
|
||||
<resources>
|
||||
<string name="mdm_host_title" translatable="false">RVS-Host</string>
|
||||
<string name="mdm_host_description" translatable="false">Hostname des RVS, z.B. aria-rvs.example.de</string>
|
||||
<string name="mdm_port_title" translatable="false">RVS-Port</string>
|
||||
<string name="mdm_tls_title" translatable="false">TLS verwenden</string>
|
||||
<string name="mdm_token_title" translatable="false">Token</string>
|
||||
<string name="mdm_token_description" translatable="false">Derselbe Token wie im QR-Code</string>
|
||||
<string name="mdm_name_title" translatable="false">Geraetename</string>
|
||||
<string name="mdm_name_description" translatable="false">So erscheint das Geraet in der Diagnostic (leer = Modellname)</string>
|
||||
<string name="mdm_control_title" translatable="false">Steuern erlauben</string>
|
||||
<string name="mdm_reply_mode_title" translatable="false">Antwort als</string>
|
||||
<string name="mdm_reply_mode_description" translatable="false">overlay (Einblendung) oder speech (Sprache)</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Werte, die ein MDM beim Ausrollen mitgeben kann (Managed Configuration).
|
||||
Sind host UND token gesetzt, verbindet sich der Agent damit — ohne QR-Code. -->
|
||||
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<restriction
|
||||
android:key="host"
|
||||
android:title="@string/mdm_host_title"
|
||||
android:description="@string/mdm_host_description"
|
||||
android:restrictionType="string" />
|
||||
<restriction
|
||||
android:key="port"
|
||||
android:title="@string/mdm_port_title"
|
||||
android:defaultValue="443"
|
||||
android:restrictionType="integer" />
|
||||
<restriction
|
||||
android:key="tls"
|
||||
android:title="@string/mdm_tls_title"
|
||||
android:defaultValue="true"
|
||||
android:restrictionType="bool" />
|
||||
<restriction
|
||||
android:key="token"
|
||||
android:title="@string/mdm_token_title"
|
||||
android:description="@string/mdm_token_description"
|
||||
android:restrictionType="string" />
|
||||
<restriction
|
||||
android:key="name"
|
||||
android:title="@string/mdm_name_title"
|
||||
android:description="@string/mdm_name_description"
|
||||
android:restrictionType="string" />
|
||||
<restriction
|
||||
android:key="control"
|
||||
android:title="@string/mdm_control_title"
|
||||
android:defaultValue="false"
|
||||
android:restrictionType="bool" />
|
||||
<restriction
|
||||
android:key="reply_mode"
|
||||
android:title="@string/mdm_reply_mode_title"
|
||||
android:description="@string/mdm_reply_mode_description"
|
||||
android:defaultValue="overlay"
|
||||
android:restrictionType="string" />
|
||||
</restrictions>
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Auto-Update: nur der Update-Ordner im Cache wird an den Installer freigegeben -->
|
||||
<!-- Auto-Update: nur Update- und Eingangsordner im Cache werden an den Installer freigegeben -->
|
||||
<paths>
|
||||
<cache-path name="updates" path="updates/" />
|
||||
<!-- Von ARIA geschickte APKs (host_command apk_install) -->
|
||||
<cache-path name="incoming" path="incoming/" />
|
||||
</paths>
|
||||
|
||||
@@ -162,7 +162,7 @@ OUT_MAX_CHARS_HARD = int(os.environ.get("OUT_MAX_CHARS_HARD", "200000") or "2000
|
||||
FILE_MAX_BYTES = int(os.environ.get("FILE_MAX_BYTES", str(10 * 1024 * 1024)) or str(10 * 1024 * 1024))
|
||||
|
||||
# Version (wird von release_agent.sh beim Release gesetzt).
|
||||
AGENT_VERSION = "0.0.1.8"
|
||||
AGENT_VERSION = "0.0.2.0"
|
||||
|
||||
HEARTBEAT_SEC = 25
|
||||
|
||||
|
||||
@@ -125,6 +125,25 @@ class NodeStats:
|
||||
txt = await _run_cmd("nvidia-smi")
|
||||
return txt or "nvidia-smi nicht verfuegbar"
|
||||
|
||||
# ── System-RAM ──────────────────────────────────────────
|
||||
def _query_ram(self) -> dict:
|
||||
"""Arbeitsspeicher der Box (used/total in MB). Wichtig, seit MoE-Modelle
|
||||
Experten in den RAM auslagern — auf der GPU sieht man das sonst nicht."""
|
||||
try:
|
||||
info = {}
|
||||
with open("/proc/meminfo") as f:
|
||||
for line in f:
|
||||
k, _, rest = line.partition(":")
|
||||
info[k.strip()] = rest
|
||||
def kb(key):
|
||||
return int(info.get(key, "0").split()[0])
|
||||
total = kb("MemTotal")
|
||||
avail = kb("MemAvailable")
|
||||
used = max(0, total - avail)
|
||||
return {"ramUsed": round(used / 1024), "ramTotal": round(total / 1024)}
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
# ── Sampler (Verlauf) ───────────────────────────────────
|
||||
async def run_sampler(self) -> None:
|
||||
while True:
|
||||
@@ -154,9 +173,10 @@ class NodeStats:
|
||||
g = await self._query_gpu()
|
||||
smi = await self._nvidia_smi_text()
|
||||
cards = await self._query_cards()
|
||||
ram = self._query_ram()
|
||||
await send(ws, "node_stats", {
|
||||
"instanceId": self.instance_id, "node": self.node_name,
|
||||
"nvidiaSmi": smi, "cards": cards, **g,
|
||||
"nvidiaSmi": smi, "cards": cards, "ram": ram, **g,
|
||||
})
|
||||
await asyncio.sleep(1)
|
||||
except asyncio.CancelledError:
|
||||
|
||||
+42
-12
@@ -705,11 +705,17 @@ def _kv_bytes(meta: dict, ctx: int) -> int:
|
||||
return per_tok * ctx + swa_tok * min(ctx, window + UBATCH)
|
||||
|
||||
|
||||
async def _auto_cpu_moe(repo: str, file: dict, vram_mb: int, ctx: int) -> int:
|
||||
async def _auto_cpu_moe(repo: str, file: dict, vram_mb: int, ctx: int) -> tuple:
|
||||
"""Wie viele Schichten mit Experten muessen in den RAM, damit der Rest auf
|
||||
die Karte passt? Holt nur den Kopf der GGUF (Metadaten + Tensor-Verzeichnis,
|
||||
wenige MB per HTTP-Range) — die Datei selbst laedt erst llama.cpp.
|
||||
0 = passt komplett, -1 = alle Experten in den RAM (oder unbekannt)."""
|
||||
Liefert (cpu_moe, ctx_fit):
|
||||
cpu_moe: 0 = passt komplett, -1 = alle Experten in den RAM (oder unbekannt)
|
||||
ctx_fit: groesster Kontext <= ctx, dessen KV-Cache selbst mit ALLEN
|
||||
Experten im RAM noch auf die Karte passt (0 = nicht mal 4k;
|
||||
None = nicht berechenbar). Ohne diese Pruefung startete z.B.
|
||||
Qwen3-Coder-30B mit ctx 262144 (24 GB KV-Cache) auf einer 12-GB-
|
||||
Karte — llama.cpp brach sofort ab, llama-swap meldete nur "500"."""
|
||||
import tempfile
|
||||
url = f"https://huggingface.co/{repo}/resolve/main/{file['path']}"
|
||||
headers = {"Range": "bytes=0-41943039"}
|
||||
@@ -729,19 +735,27 @@ async def _auto_cpu_moe(repo: str, file: dict, vram_mb: int, ctx: int) -> int:
|
||||
os.unlink(tmp)
|
||||
except Exception as e:
|
||||
logger.warning("MoE-Aufteilung fuer %s nicht berechenbar (%s) — alle Experten in den RAM", repo, e)
|
||||
return -1
|
||||
return -1, None
|
||||
exp = meta.get("_expert_bytes_by_layer") or {}
|
||||
if not exp:
|
||||
return 0 # kein MoE
|
||||
return 0, None # kein MoE
|
||||
total_mb = int(file.get("size") or 0) / 1048576
|
||||
exp_mb = sum(exp.values()) / 1048576
|
||||
budget = vram_mb * 0.92 - VRAM_OVERHEAD_MB - _kv_bytes(meta, ctx) / 1048576 - (total_mb - exp_mb)
|
||||
# Was bleibt auf der Karte, wenn ALLE Experten im RAM liegen? Davon muss
|
||||
# der KV-Cache leben — sonst passt das Modell bei keiner Aufteilung.
|
||||
free_for_kv = vram_mb * 0.92 - VRAM_OVERHEAD_MB - (total_mb - exp_mb)
|
||||
ctx_fit = 0
|
||||
for c in [s for s in CTX_STEPS if s <= ctx] + ([ctx] if ctx not in CTX_STEPS else []):
|
||||
if _kv_bytes(meta, c) / 1048576 <= free_for_kv:
|
||||
ctx_fit = max(ctx_fit, c)
|
||||
use_ctx = ctx_fit or ctx
|
||||
budget = free_for_kv - _kv_bytes(meta, use_ctx) / 1048576
|
||||
per_layer = exp_mb / len(exp)
|
||||
on_gpu = max(0, int(budget // per_layer)) if per_layer else 0
|
||||
n = max(0, len(exp) - on_gpu)
|
||||
logger.info("MoE %s: %d von %d Schichten mit Experten in den RAM (Karte %d MB, ctx %d)",
|
||||
repo, n, len(exp), vram_mb, ctx)
|
||||
return -1 if n >= len(exp) else n
|
||||
logger.info("MoE %s: %d von %d Schichten mit Experten in den RAM (Karte %d MB, ctx %d, passt bis ctx %d)",
|
||||
repo, n, len(exp), vram_mb, ctx, ctx_fit)
|
||||
return (-1 if n >= len(exp) else n), ctx_fit
|
||||
|
||||
|
||||
def _model_files(key: str) -> tuple:
|
||||
@@ -1704,13 +1718,29 @@ async def _do_provision(ws, payload: dict, job: dict) -> None:
|
||||
cpu_moe = int(payload.get("cpuMoe") or 0)
|
||||
except (TypeError, ValueError):
|
||||
cpu_moe = 0
|
||||
if cpu_moe == -2:
|
||||
# "automatisch verteilen": so viele Experten auf die Karte wie passen
|
||||
if cpu_moe in (-1, -2):
|
||||
# MoE mit Experten im RAM: Der KV-Cache bleibt IMMER auf der Karte.
|
||||
# Passt er beim gewuenschten Kontext nicht, Kontext kuerzen statt
|
||||
# llama.cpp still abstuerzen zu lassen.
|
||||
qfiles = _files_for_quant(repo_files, quant) if repo_files else []
|
||||
vram = int(((await _gpu_names()).get(card) or {}).get("vramMB") or 0)
|
||||
if len(qfiles) == 1 and vram:
|
||||
cpu_moe = await _auto_cpu_moe(repo, qfiles[0], vram, ctx_req)
|
||||
else:
|
||||
auto, ctx_fit = await _auto_cpu_moe(repo, qfiles[0], vram, ctx_req)
|
||||
if cpu_moe == -2:
|
||||
# "automatisch verteilen": so viele Experten auf die Karte wie passen
|
||||
cpu_moe = auto
|
||||
if ctx_fit == 0:
|
||||
msg = (f"{repo}: passt nicht auf Karte {card} ({vram // 1024} GB) — schon "
|
||||
f"ohne Experten reicht der Platz nicht einmal fuer 4k Kontext.")
|
||||
await _emit_progress(ws, key, "error", gpu=card, error=msg)
|
||||
return await _provision_result(ws, key, False, gpu=card, error=msg)
|
||||
if ctx_fit and ctx_fit < ctx_req:
|
||||
note = (f"Kontext von {ctx_req // 1024}k auf {ctx_fit // 1024}k gekuerzt — "
|
||||
f"mehr passt als KV-Cache nicht auf die {vram // 1024}-GB-Karte")
|
||||
logger.info("Karte %s: %s", card, note)
|
||||
quant_note = "; ".join(x for x in (quant_note, note) if x)
|
||||
ctx_req = ctx_fit
|
||||
elif cpu_moe == -2:
|
||||
cpu_moe = -1 # gesplittete Datei / Karte unbekannt: alle in den RAM
|
||||
entry = {
|
||||
"key": key, "hfRepo": repo, "quant": quant,
|
||||
|
||||
@@ -125,6 +125,25 @@ class NodeStats:
|
||||
txt = await _run_cmd("nvidia-smi")
|
||||
return txt or "nvidia-smi nicht verfuegbar"
|
||||
|
||||
# ── System-RAM ──────────────────────────────────────────
|
||||
def _query_ram(self) -> dict:
|
||||
"""Arbeitsspeicher der Box (used/total in MB). Wichtig, seit MoE-Modelle
|
||||
Experten in den RAM auslagern — auf der GPU sieht man das sonst nicht."""
|
||||
try:
|
||||
info = {}
|
||||
with open("/proc/meminfo") as f:
|
||||
for line in f:
|
||||
k, _, rest = line.partition(":")
|
||||
info[k.strip()] = rest
|
||||
def kb(key):
|
||||
return int(info.get(key, "0").split()[0])
|
||||
total = kb("MemTotal")
|
||||
avail = kb("MemAvailable")
|
||||
used = max(0, total - avail)
|
||||
return {"ramUsed": round(used / 1024), "ramTotal": round(total / 1024)}
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
# ── Sampler (Verlauf) ───────────────────────────────────
|
||||
async def run_sampler(self) -> None:
|
||||
while True:
|
||||
@@ -154,9 +173,10 @@ class NodeStats:
|
||||
g = await self._query_gpu()
|
||||
smi = await self._nvidia_smi_text()
|
||||
cards = await self._query_cards()
|
||||
ram = self._query_ram()
|
||||
await send(ws, "node_stats", {
|
||||
"instanceId": self.instance_id, "node": self.node_name,
|
||||
"nvidiaSmi": smi, "cards": cards, **g,
|
||||
"nvidiaSmi": smi, "cards": cards, "ram": ram, **g,
|
||||
})
|
||||
await asyncio.sleep(1)
|
||||
except asyncio.CancelledError:
|
||||
|
||||
@@ -125,6 +125,25 @@ class NodeStats:
|
||||
txt = await _run_cmd("nvidia-smi")
|
||||
return txt or "nvidia-smi nicht verfuegbar"
|
||||
|
||||
# ── System-RAM ──────────────────────────────────────────
|
||||
def _query_ram(self) -> dict:
|
||||
"""Arbeitsspeicher der Box (used/total in MB). Wichtig, seit MoE-Modelle
|
||||
Experten in den RAM auslagern — auf der GPU sieht man das sonst nicht."""
|
||||
try:
|
||||
info = {}
|
||||
with open("/proc/meminfo") as f:
|
||||
for line in f:
|
||||
k, _, rest = line.partition(":")
|
||||
info[k.strip()] = rest
|
||||
def kb(key):
|
||||
return int(info.get(key, "0").split()[0])
|
||||
total = kb("MemTotal")
|
||||
avail = kb("MemAvailable")
|
||||
used = max(0, total - avail)
|
||||
return {"ramUsed": round(used / 1024), "ramTotal": round(total / 1024)}
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
# ── Sampler (Verlauf) ───────────────────────────────────
|
||||
async def run_sampler(self) -> None:
|
||||
while True:
|
||||
@@ -154,9 +173,10 @@ class NodeStats:
|
||||
g = await self._query_gpu()
|
||||
smi = await self._nvidia_smi_text()
|
||||
cards = await self._query_cards()
|
||||
ram = self._query_ram()
|
||||
await send(ws, "node_stats", {
|
||||
"instanceId": self.instance_id, "node": self.node_name,
|
||||
"nvidiaSmi": smi, "cards": cards, **g,
|
||||
"nvidiaSmi": smi, "cards": cards, "ram": ram, **g,
|
||||
})
|
||||
await asyncio.sleep(1)
|
||||
except asyncio.CancelledError:
|
||||
|
||||
@@ -125,6 +125,25 @@ class NodeStats:
|
||||
txt = await _run_cmd("nvidia-smi")
|
||||
return txt or "nvidia-smi nicht verfuegbar"
|
||||
|
||||
# ── System-RAM ──────────────────────────────────────────
|
||||
def _query_ram(self) -> dict:
|
||||
"""Arbeitsspeicher der Box (used/total in MB). Wichtig, seit MoE-Modelle
|
||||
Experten in den RAM auslagern — auf der GPU sieht man das sonst nicht."""
|
||||
try:
|
||||
info = {}
|
||||
with open("/proc/meminfo") as f:
|
||||
for line in f:
|
||||
k, _, rest = line.partition(":")
|
||||
info[k.strip()] = rest
|
||||
def kb(key):
|
||||
return int(info.get(key, "0").split()[0])
|
||||
total = kb("MemTotal")
|
||||
avail = kb("MemAvailable")
|
||||
used = max(0, total - avail)
|
||||
return {"ramUsed": round(used / 1024), "ramTotal": round(total / 1024)}
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
# ── Sampler (Verlauf) ───────────────────────────────────
|
||||
async def run_sampler(self) -> None:
|
||||
while True:
|
||||
@@ -154,9 +173,10 @@ class NodeStats:
|
||||
g = await self._query_gpu()
|
||||
smi = await self._nvidia_smi_text()
|
||||
cards = await self._query_cards()
|
||||
ram = self._query_ram()
|
||||
await send(ws, "node_stats", {
|
||||
"instanceId": self.instance_id, "node": self.node_name,
|
||||
"nvidiaSmi": smi, "cards": cards, **g,
|
||||
"nvidiaSmi": smi, "cards": cards, "ram": ram, **g,
|
||||
})
|
||||
await asyncio.sleep(1)
|
||||
except asyncio.CancelledError:
|
||||
|
||||
Reference in New Issue
Block a user