Skills von pixel: artifacts-overview/SKILL.md autonomous-ai-agents/hermes-a2a devops/peer-dashboard web-content-accreation-fallback/SKILL.md
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
---
|
||||
name: artifacts-overview
|
||||
category: software-development
|
||||
description: "Use when creating local Artifacts-HTML on Termux/Android."
|
||||
---
|
||||
|
||||
# Artifacts-Overview (Hermes / Termux-Android)
|
||||
|
||||
Lokale "Artifacts"-Seiten im Claude-Artifacts-Stil: self-contained HTML (inline CSS, keine CDNs, deutsch),
|
||||
serviert unter `http://127.0.0.1:8787/`, Browser via Android-Intent öffnen.
|
||||
|
||||
## When to Use
|
||||
- Du sollst aus Dokumenten/Inhalten eine lokal angezeigte HTML-Seite bauen (z. B. aus Google-Docs, PDFs, Notizen).
|
||||
- Du sollst die bestehende Artifact-Übersicht auflisten, aktualisieren oder neu sortieren.
|
||||
- Du bearbeitest ein vorhandenes Artifact und die Reihenfolge ("Letzte Interaktion") danach anpassen.
|
||||
- Du stehst auf dem Termux/Android-Stack und brauchst self-contained, offline-fähige HTML ohne Build.
|
||||
|
||||
AUßER: reine Markdown-/Textantwort genügt, oder es geht um Server-seitige Apps — dann nicht anwenden.
|
||||
|
||||
## Dateien (alle unter `~/artifacts` = `/data/data/com.termux/files/home/artifacts`)
|
||||
|
||||
| Datei | Zweck |
|
||||
|---|---|
|
||||
| `artifacts.json` | Registry aller Artifacts. Schema: `{"artifacts":[{"id","file","title","subtitle","tags":[],"created":ms,"updated":ms}]}`. **`updated` = letzte Interaktion** — der Index sortiert danach absteigend. |
|
||||
| `_template.artifact.html` | **Pflicht-Template** für neue Artifacts. Enthält den **Zurück-Button** (`a.back-btn` → `index.html`), Hero, `.card`-Sektionen, Footer, relative-Zeit-RS. Platzhalter: `@@TITEL@@`, `@@TEASER@@`, `@@QUELLE@@`, `@@QUELLE_URL@@`, `@@CREATED_MS@@`, `@@UPDATED_MS@@`. |
|
||||
| `gen_index.py` | Generiert `index.html` aus `artifacts.json` (Sortierung: absteigend nach `updated`). Aufruf: `python3 ~/artifacts/gen_index.py`. |
|
||||
| `index.html` | Übersicht (auto-generiert): sortierte Karten (Titel, Subtitle, Tags, relative + absolute Zeit), oberster Eintrag mit "Neueste"-Badge. |
|
||||
|
||||
## Workflow für ein neues Artifact
|
||||
1. Template kopieren: `cp ~/artifacts/_template.artifact.html ~/artifacts/<slug>.html`
|
||||
2. Platzhalter **als nackte `@@NAME@@`-Tokens** ersetzen; Inhalt als `.card`-Sektionen bauen (KV-Listen via `<dl class="kv">`). Danach prüfen, dass keine `@@`-Tokens übrig sind (s. Pitfalls).
|
||||
3. Eintrag in `artifacts.json` anlegen: `updated` = `int(time.time()*1000)`, `file` = Dateiname.
|
||||
4. `python3 ~/.artifacts/gen_index.py` ausführen.
|
||||
5. Server-Check (Port 8787; muss **nicht** bereits laufen, häufig tot): `curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8787/index.html` → 200. Falls tot (000): `python3 -m http.server 8787 --bind 127.0.0.1 --directory ~/artifacts` mit terminal-Tool `background=true, persist_on_release=true` starten, `sleep 1`, dann curl erneut → 200 bestätigen.
|
||||
6. Browser öffnen: `am start -a android.intent.action.VIEW -d "http://127.0.0.1:8787/index.html"` (oder direkt die artifact-URL).
|
||||
|
||||
## Bei Interaktion mit einem bestehenden Artifact
|
||||
- HTML aktualisieren **und** zugehöriges `updated` in `artifacts.json` auf jetzt setzen,
|
||||
- dann `gen_index.py` neu laufen lassen → Reihenfolge in der Übersicht passt automatisch.
|
||||
|
||||
## Pitfalls
|
||||
- **Kein `/tmp`** auf Termux für Nutzerdateien — Scratch: `/data/data/com.termux/files/home/.hermes/cache/scratch/`.
|
||||
- **Ordner heißt `~/artifacts` (OHNE Punkt)** — `~/.artifacts/` existiert nicht; ältere Notizen und der Template-Kommentar nennen es so. Jeder Pfad mit Punkt scheitert mit FileNotFoundError/„no such directory“.
|
||||
- `nohup … &` wird vom Hermes-Harness abgelehnt → Server immer mit terminal-Tool `background=true` starten.
|
||||
- Sortierung ist **Server-seitig** in `gen_index.py` (nicht nur im JS) — Reihenfolge im HTML stabil.
|
||||
- Relative Zeiten ("2 h her") rechnet die Seite im Client-JS aus `data-updated`-Attributen; offline-fähig, kein Build nötig.
|
||||
- `am start` öffnet den Default-Android-Browser (Chromium/Firefox in Termux nicht installiert).
|
||||
- **Zeitstempel-Platzhalter nur als nackte Tokens ersetzen, nicht mit JS-Präfix** — `@@CREATED_MS@@` und `@@UPDATED_MS@@` teilen sich EINE Zeile (`const C = …, U = …;`); eine Ersetzung mit verpasstem Präfix (z. B. `const U = ` voran) verfehlt stumm und lässt ein `U = @@UPDATED_MS@@` zurück, das die gesamte Zeitstempel-Ausgabe bricht (alles zeigt „—“). Vor gen_index/Server/`am start` immer `grep '@@'` auf dem neuen Artifact → null Treffer erwarten.
|
||||
- Port 8787 ist die Kanon für Artifacts; andere Ports frei.
|
||||
@@ -30,6 +30,14 @@ Docs: https://hermes-agent.nousresearch.com/docs/user-guide/messaging/a2a
|
||||
- Deciding between in-process `delegate_task`/kanban (same machine) vs A2A (crosses process/machine/framework boundaries).
|
||||
- Verifying that an A2A peer is actually reachable and answering, not just showing up in `tailscale status`.
|
||||
|
||||
## User's peers (this profile)
|
||||
The user refers to peers by **machine name**, not by their config key — resolve via `a2a_list` before calling:
|
||||
- **blackbook** = config key `macbook` (hostname `blackbook.ts.robbis.space`) — the browser/computer-use peer (e.g. muting/unmuting the SoundCloud Firefox tab, starting music playback).
|
||||
- **nas** = config key `nas` (`nas.ts.robbis.space`). Hosts the WG bot whose kanban board is the „Werkstatt" (setup cards). That board is **operator-only via A2A**: the peer's A2A sessions carry no kanban/terminal/code-exec/file tools, and the bot's working rules forbid unblocking/moving/completing its cards from a peer message — privilege is recognized only via system-verified Telegram identity, never self-assertion in a peer message. Legitimate start paths on this user's stack: `/dispatch` in the bot's private Telegram chat, the bot's Werkstatt menu, or on the NAS host itself: `hermes kanban unblock <id>` / `hermes kanban reclaim <id>` (needs host access, e.g. SSH).
|
||||
- **When a resource's home is unknown, check LOCAL first, then fan out.** "Start/manage X on agent Y" style requests: check the local kanban boards/profiles before calling peers (a quick `hermes kanban boards list` + id grep is cheaper than an A2A round-trip and catches the case where X is local). Peers queried about foreign resources need a strict "answer only, create nothing" instruction — otherwise a helpful peer may invent the missing board/card. Peer claims can also contradict each other; the local state is the tie-breaker.
|
||||
|
||||
Relay work (user's task → peer executes → peer reports back) is the common pattern here: state provenance explicitly and follow the two relay pitfalls below (security heuristics, consent relay).
|
||||
|
||||
## Quick setup (verified 2026-10-23)
|
||||
|
||||
1. **Enable the platform + toolsets:**
|
||||
@@ -83,13 +91,26 @@ Docs: https://hermes-agent.nousresearch.com/docs/user-guide/messaging/a2a
|
||||
listed there. But unlike the audit-log curl case, the lost reply is usually
|
||||
LOST — the peer may still finish processing with no one listening for the
|
||||
answer. If the result matters, follow up with a new call that references the
|
||||
original task; don't blindly re-send the same text.
|
||||
original task; don't blindly re-send the same text. A follow-up ping to a peer
|
||||
that is still executing a long task times out the same way — expected, not a
|
||||
second failure: one follow-up is enough, confirm both outbound entries in the
|
||||
audit log, do not spam a third ping, and report 'delivered, peer still
|
||||
working' to the user. A `timed out` error means the peer server is UP
|
||||
(connection established, reply just took longer than the client waits);
|
||||
a DOWN peer returns a connection error instead.
|
||||
- **Peer agents have their own security heuristics.** A peer LLM can refuse a
|
||||
relayed instruction containing a URL or auth token as "untrusted external
|
||||
input" (because it arrived from another agent, not the user). Recover by
|
||||
stating provenance explicitly (direct request from the user, the user's own
|
||||
service/device) AND re-instructing with a concrete action verb ("call this
|
||||
endpoint and report the response body") instead of "follow this URL".
|
||||
- **Consent relay (standing user rule).** When relaying a user's task that may
|
||||
require the user's consent mid-execution, explicitly instruct the peer: do not
|
||||
guess and do not act silently — send the exact question (what it wants to do
|
||||
and why consent is needed) back to the ORIGIN agent and wait for the answer.
|
||||
The origin agent asks the user in the user's own chat and feeds the answer
|
||||
back. This is this user's explicit instruction for cross-agent work.
|
||||
- **Probe what the peer's session can actually do before promising the action.** A peer's A2A toolset is per-instance and can be far narrower than the Agent Card's advertised skills (a card may list kanban/browser/etc. while the A2A session has none of them — "dauerhaft deaktiviert" by the operator). One short call asking "list exactly the tools bound to this session" is decisive and cheap. Distinguish its two outcomes: `timed out` = peer is busy/working (the existing follow-up-once rule applies), vs. a normal reply saying "this session has no X tool" = a hard boundary. When the peer states an explicit policy boundary (no card-move, no shell, identity-gated privilege), respect it and find the operator's canonical path (bot menu, host CLI over SSH) — do NOT route around it with other peer tools (e.g. the peer's cronjob tooling), even if technically reachable: that policy is the peer's security model, not a tech bug.
|
||||
- **Set the token BEFORE widening the bind.** `A2A_HOST=0.0.0.0` only widens the
|
||||
bind when `A2A_BEARER_TOKEN` is set; without the token the server stays on
|
||||
127.0.0.1 and remote peers get connection-refused.
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: peer-dashboard
|
||||
description: Use when creating a peer HTML artifact on Termux/Android.
|
||||
category: devops
|
||||
---
|
||||
# Creating a Peer Dashboard
|
||||
|
||||
## Trigger
|
||||
Use when the user asks for a live dashboard showing active peer connections, updated regularly, delivered as an HTML artifact on Termux/Android.
|
||||
|
||||
## Procedure
|
||||
1. Verify VPN connectivity – run `tailscale --socket=/data/data/com.termux/files/usr/var/run/tailscaled.sock status` and confirm at least one peer is reachable.
|
||||
2. Create the daemon script – write `daemon.py` with a `tailnet()` function that calls the VPN status command, matches JSON peers to HTML rows using a two‑pass algorithm (name‑score ≥2 first pass, then unique OS match in second pass), marks the local device (`android-termux`) with `online: null` and displays "(local)" on the HTML page, and writes the result to `peers.data.json` once per minute.
|
||||
3. Write the HTML artifact – create `peer-dashboard.html` (inline CSS, dark theme, German text). The page must poll `peer_dashboard/peers.data.json` every 30 s, show live pills for VPN status, sync, and last‑check time, render a grid of peer cards with name, status badge, agent name/version, URL, latency, and consecutive failures, display a Tailnet‑Knoten table with name, IP, OS, user, and online/offline/— status, mark the local node with a “lokal” badge, and render a 24‑h timeline with 30‑min slots (green = reachable, yellow = slow >500 ms, red = offline, grey = no data), include a footer linking to the source JSON.
|
||||
4. Register the artifact – add an entry to `artifacts.json` and run `python3 gen_index.py` to update `index.html`.
|
||||
5. Start the background services –
|
||||
```bash
|
||||
python3 /data/data/com.termux/files/home/artifacts/peer_dashboard/daemon.py loop background persist_on_release true
|
||||
python3 -m http.server 8787 --bind 127.0.0.1 --directory /data/data/com.termux/files/home/artifacts background persist_on_release true
|
||||
```
|
||||
6. Open the dashboard – `am start -a android.intent.action.VIEW -d "http://127.0.0.1:8787/peer-dashboard.html"` or open via the Android browser.
|
||||
|
||||
## Pitfalls
|
||||
- Mis‑matched peers – the first fuzzy‑match may assign `android-termux` to the `pixel` peer because both contain "android". Use the two‑pass algorithm above to avoid this.
|
||||
- Local‑device leakage – if the local device appears in the JSON peer list, set its `online` to `null` and display it as "(local)" rather than letting it compete with real peers.
|
||||
- Stale HTTP server – after a session restart kill any existing `python -m http.server 8787` before starting a new one.
|
||||
- HTML lint errors – auto‑syntax check only covers .py/.json etc.; for pure HTML do a quick visual check or `node --check` on the `<script>` block.
|
||||
- **Fuzzy‑patch drift when editing daemon.py/HTML** – the patch tool's fuzzy/block‑anchor matcher can apply your hunk to a *different* code block than intended while still reporting success with a plausible diff (new text lands wrong / different block replaced). After each patch in a busy file: `grep -F` the new sentinel string and confirm the old one is gone before continuing; "success" + a clean diff is not proof the intended change landed.
|
||||
|
||||
## Always‑on rules (user preferences)
|
||||
- Dashboard text in German.
|
||||
- Dark‑theme colour palette.
|
||||
- Daemon checks every 60 s; HTML refreshes every 30 s.
|
||||
- No external resources – all assets must be in‑page or local.
|
||||
|
||||
# References
|
||||
- `references/matching-algorithm.md` – detailed two‑pass peer‑assignment algorithm and score functions.
|
||||
- `references/tailscale-commands.md` – common `tailscale` CLI invocations for this environment.
|
||||
@@ -0,0 +1,42 @@
|
||||
# Two‑Pass Peer Assignment Algorithm
|
||||
|
||||
## Score function
|
||||
|
||||
```python
|
||||
def score(row, j):
|
||||
s = 0
|
||||
name = row["name"].lower()
|
||||
if name and name in j["hostname"]:
|
||||
s += 3
|
||||
elif j["hostname"] and j["hostname"] in name:
|
||||
s += 2
|
||||
if j["os"] and j["os"] == row["os"].lower():
|
||||
s += 1
|
||||
return s
|
||||
```
|
||||
|
||||
## Pass 1 – name‑based match (score ≥ 2)
|
||||
|
||||
1. For each HTML row, scan all remaining JSON peers.
|
||||
2. Compute `score(row, j)` as above.
|
||||
3. Pick the peer with the highest score.
|
||||
4. If `best_score ≥ 2`, mark the peer as used and attach its `online`, `last_handshake`, `version` to the row.
|
||||
5. If no peer reaches `≥ 2`, the row gets `online: null, last_handshake: null, version: ""`.
|
||||
|
||||
## Pass 2 – unique OS match (only when exactly one row and one JSON peer share the OS)
|
||||
|
||||
1. After pass 1, collect remaining open rows and JSON peers.
|
||||
2. For each row where `online` is still missing:
|
||||
* Count how many open rows have the same `os` (lower‑cased).
|
||||
* Count how many open JSON peers have the same `os`.
|
||||
* If **both counts are exactly 1**, assign that peer to that row (score ≥ 1 is sufficient).
|
||||
* Otherwise, skip the row – it will be filled with `online: null` later.
|
||||
|
||||
## Why two passes?
|
||||
|
||||
* A pure greedy name‑match can mis‑assign peers whose hostnames share substrings (e.g., `android-termux` vs `pixel`).
|
||||
* Enforcing a 1‑to‑1 OS‑match in pass 2 guarantees that a peer is only claimed when it is the *sole* candidate for that OS, preventing double‑booking and the “pixel‑slot‑theft” bug that appeared in earlier versions.
|
||||
|
||||
## Local‑device handling
|
||||
|
||||
The current device (`android-termux`) is excluded from the JSON peer pool before assignment begins. On the HTML page it is displayed with the badge `lokal` and `online: –‑` to avoid it competing with real peers.
|
||||
@@ -0,0 +1,33 @@
|
||||
# Common Tailscale CLI invocations (Termux/Android)
|
||||
|
||||
## Check status (uses local socket)
|
||||
|
||||
```bash
|
||||
tailscale --socket=/data/data/com.termux/files/usr/var/run/tailscaled.sock status
|
||||
```
|
||||
|
||||
## Bring up the local device (if not yet authorised)
|
||||
|
||||
```bash
|
||||
tailscale up --advertise-routes=100.64.0.0/10 --accept-dns=false
|
||||
```
|
||||
|
||||
## List all peers with IP, OS and labels
|
||||
|
||||
```bash
|
||||
tailscale --socket=/data/data/com.termux/files/usr/var/run/tailscaled.sock status --json | python3 -c "import sys,json; d=json.load(sys.stdin); [print(f'{k}: {v[\"addr\"]} {v[\"hostName\"]} {v[\"os\"]} {v[\"tags\"]}') for k,v in d[\"PeerMap\"].items()]"
|
||||
```
|
||||
|
||||
## Refresh lease / re‑authorise
|
||||
|
||||
```bash
|
||||
tailscale up --reset
|
||||
```
|
||||
|
||||
## Export peer data for the dashboard daemon
|
||||
|
||||
The daemon (`daemon.py`) runs:
|
||||
|
||||
```bash
|
||||
tailscale --socket=/data/data/com.termux/files/usr/var/run/tailscaled.sock status --json > /data/data/com.termux/files/home/artifacts/peer_dashboard/peers.data.json
|
||||
```
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
name: web-content-acquisition
|
||||
description: Use when fetching a URL's content headlessly (page or doc).
|
||||
---
|
||||
|
||||
# Fetching URL content headlessly
|
||||
|
||||
Class: turn a URL into the document's actual text. Do not open a GUI browser to *look* at it — in a headless CLI there is no window to show. Pick the cheapest reliable retrieval and validate each one.
|
||||
|
||||
## Method order (cheapest first; confirm each works before moving on)
|
||||
1. **Shared doc → no-JS export endpoint** (works for anyone-with-link Google Docs/Sheets/Slides; no JS, no login).
|
||||
- Docs: `https://docs.google.com/document/d/<ID>/export?format=txt` (also `docx`, `pdf`)
|
||||
- Sheets: `https://docs.google.com/spreadsheets/d/<ID>/export?format=csv`
|
||||
- Success signal: HTTP 200, `content-type: text/plain`, or a redirect to `*.googleusercontent.com` with real bytes back. A login/consent redirect instead = private doc → go to 2/3.
|
||||
2. **web_extract** — only when `web.extract_backend` is a *content* backend (firecrawl / tavily / keenable / exa / parallel). A search-only backend (e.g. brave-free) cannot fetch page content and errors out; that is a config gap, not a dead end — point the backend at a content provider and it works.
|
||||
3. **Browser (agent-browser)** — for interactive/JS-only pages, or when the user needs the editable UI. Getting a runnable browser on this Termux/Android host is non-trivial — see `references/setup-termux.md`, and prefer 1/2 whenever the content is reachable without it.
|
||||
|
||||
## Standing gotchas (this host)
|
||||
- No `/tmp`. Write downloads and exports to the scratch dir (`$BH_AGENT_WORKSPACE` or `~/.hermes/cache/scratch`); a `curl -o /tmp/...` will fail with a write error.
|
||||
- `os.platform()` here is `android`; binaries and tools that assume `linux`, or a platform they don't ship, mis-resolve. Check what actually runs rather than what the name says.
|
||||
|
||||
## After fetching
|
||||
- Present the content. Offer the interactive editor path only if the user genuinely must edit (that needs their own Google login) — and say up front that the headless CLI has no GUI to display the editor in.
|
||||
Reference in New Issue
Block a user