Skills von pixel: autonomous-ai-agents/hermes-a2a software-development/android-debugging-from-termux software-development/termux-go-builds
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
---
|
||||
name: hermes-a2a
|
||||
description: "Connect Hermes agents over A2A: setup, peers, verify."
|
||||
version: 1
|
||||
author: "Hermes Agent"
|
||||
license: MIT
|
||||
metadata:
|
||||
hermes:
|
||||
tags: [a2a, agents, multi-agent, hermes, tailnet, delegation]
|
||||
related_skills: [hermes-agent, termux-go-builds]
|
||||
---
|
||||
|
||||
# Hermes A2A (Agent-to-Agent) — connecting agents to each other
|
||||
|
||||
A2A is the open Agent2Agent protocol (v1.0) for inter-agent communication.
|
||||
The Hermes A2A plugin is bidirectional:
|
||||
- **Inbound**: your Hermes serves an Agent Card + JSON-RPC 2.0 endpoint (port 9900)
|
||||
→ other agents can send you tasks.
|
||||
- **Outbound**: the `a2a` toolset gives YOUR agent tools to call other agents
|
||||
(`a2a_discover`, `a2a_call`, `a2a_list`, `a2a_history`, `a2a_orchestrate`).
|
||||
|
||||
Use A2A when crossing process/machine/framework boundaries. For multiple agents
|
||||
on the SAME machine, prefer `delegate_task` (in-process) or the kanban board.
|
||||
|
||||
Docs: https://hermes-agent.nousresearch.com/docs/user-guide/messaging/a2a
|
||||
|
||||
## When to Use
|
||||
- The user wants two Hermes agents (or a Hermes agent and any other agent) to talk to each other, send tasks, or chain multi-agent work across machines.
|
||||
- Setting up or debugging an A2A inbound/outbound connection (port 9900, bearer token, peer registration).
|
||||
- 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`.
|
||||
|
||||
## Quick setup (verified 2026-10-23)
|
||||
|
||||
1. **Enable the platform + toolsets:**
|
||||
```bash
|
||||
hermes config set gateway.platforms.a2a.enabled true
|
||||
hermes tools enable a2a --platform cli
|
||||
hermes tools enable a2a --platform a2a # lets inbound tasks call peers (agent chaining)
|
||||
```
|
||||
2. **Tokens & bind (in `~/.hermes/.env` — credentials go in .env, never config.yaml).**
|
||||
Generate a token: `python3 -c "import secrets;print(secrets.token_hex(24))"`.
|
||||
```
|
||||
A2A_BEARER_TOKEN=<64-hex>
|
||||
A2A_HOST=0.0.0.0 # widens bind ONLY when a token is set (security invariant)
|
||||
A2A_PORT=9900
|
||||
A2A_PUBLIC_URL=http://<node>.<tailnet-domain>:9900 # routable URL the Agent Card advertises
|
||||
A2A_AGENT_NAME=<name>
|
||||
```
|
||||
Security model: **no token ⇒ binds 127.0.0.1 only.** Remote exposure requires a
|
||||
bearer token AND `A2A_HOST`. Per-peer alt: `A2A_PEER_TOKENS="alice:tok1,bob:tok2"`.
|
||||
3. **Register peers** (each peer must point at the OTHER's public URL + same token):
|
||||
```bash
|
||||
hermes config set a2a_agents.<peer>.url "http://<peer>.<domain>:9900" --force
|
||||
hermes config set a2a_agents.<peer>.auth.type bearer --force
|
||||
hermes config set a2a_agents.<peer>.auth.token "<same A2A_BEARER_TOKEN>" --force
|
||||
```
|
||||
4. **Start the gateway** in its own tmux session (survives session churn):
|
||||
```bash
|
||||
tmux new-session -d -s gateway 'env TERM=xterm hermes gateway run 2>&1 | tee -a ~/.hermes/logs/gateway-run.log'
|
||||
```
|
||||
|
||||
## Verification (do this — don't trust the config)
|
||||
- Agent Card: `curl -sS http://127.0.0.1:9900/.well-known/agent-card.json` → JSON with `name` and `url`.
|
||||
- Inbound task:
|
||||
```bash
|
||||
curl -sS -X POST http://127.0.0.1:9900/ -H 'Authorization: Bearer <tok>' \
|
||||
-d '{"jsonrpc":"2.0","id":1,"method":"SendMessage","params":{"message":{"messageId":"m1","role":"ROLE_USER","parts":[{"text":"hi"}]}}}'
|
||||
```
|
||||
- **The audit log is the source of truth**: `~/.hermes/a2a_audit.jsonl` records
|
||||
inbound/outbound task + reply even when the HTTP response is lost. If you see
|
||||
an `inbound` and a matching `outbound` line, the round-trip worked.
|
||||
|
||||
## Pitfalls (hit in-session)
|
||||
- **curl timeout ≠ failure.** A self-test that times out (e.g. `-m 40`) can still
|
||||
have a COMPLETE audit-log entry (inbound task + outbound reply). Check
|
||||
`a2a_audit.jsonl` before concluding A2A is broken. A long LLM reply easily
|
||||
exceeds a short curl timeout; the server logs `BrokenPipeError` after the client
|
||||
gave up — that is a client-side timeout, not a server failure.
|
||||
- **Same rule for a client-timed-out `a2a_call` — with one twist.** A client
|
||||
timeout does not mean the task wasn't delivered: `a2a_list` (outbound count
|
||||
rose) and the conversation's `a2a_history` prove delivery if your message is
|
||||
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.
|
||||
- **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".
|
||||
- **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.
|
||||
- **Peers must be running too.** A node showing in `tailscale status --peers` is
|
||||
NOT the same as its A2A server being up. Verify each peer's card first:
|
||||
`curl -m 5 http://<peer>.<domain>:9900/.well-known/agent-card.json`.
|
||||
- **Token must match on BOTH sides.** A mismatch does NOT always return HTTP 401 —
|
||||
verified in-session: the peer answered `HTTP 200` with a JSON-RPC error body
|
||||
`{"code": -32050, "message": "unauthorized"}`. Treat `-32050 unauthorized` as the
|
||||
token-mismatch signature (card fetch needs no auth, so a 200 card + -32050 task call =
|
||||
network fine, auth wrong).
|
||||
- **`a2a_agents` is a custom top-level key** — `hermes config set` warns "not a
|
||||
recognized config key"; use `--force`. It works and is read by the plugin.
|
||||
- **Magic DNS may not exist for the tailnet.** `<node>.<zone>` URLs (in
|
||||
`A2A_PUBLIC_URL`, peer `url`s, and the advertised Agent Card `url`) only resolve
|
||||
if the control server has Magic DNS enabled for that zone. Symptom that bites:
|
||||
even your OWN node's advertised URL fails with `curl: (6) Could not resolve
|
||||
host` — the card is fine, the name just doesn't exist. Fix: enable Magic DNS on
|
||||
the control server, or switch all references to the CGNAT address
|
||||
(`tailscale ip -4` → `http://100.x.y.z:9900`) and regenerate `A2A_PUBLIC_URL`.
|
||||
Diagnosis order when a peer is "unreachable": `curl (6)` = DNS, fix the name;
|
||||
`curl (7) Failed to connect` = port closed, the peer's A2A server genuinely
|
||||
isn't running (most common). A node in `tailscale status` does not imply either.
|
||||
|
||||
## Templates
|
||||
- `templates/a2a-peer-setup.sh` — idempotent per-peer inbound setup (enables the
|
||||
platform/toolsets, derives the tailnet IP via `tailscale ip -4` so it works
|
||||
without Magic DNS, sets A2A_* env vars incl. token, self-tests the card).
|
||||
Run it on EVERY box that must receive A2A tasks.
|
||||
|
||||
## See also
|
||||
- Tailscale networking that A2A often rides over: see the `termux-go-builds` skill (references/tailscale-android.md there) for Termux/Android bring-up.
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# a2a-peer-setup.sh — A2A inbound on a Hermes peer box (verified pattern, 2026-10-23)
|
||||
#
|
||||
# Run on EVERY box that must RECEIVE A2A tasks (NAS, RPi, MacBook, …).
|
||||
# bash a2a-peer-setup.sh [AGENT_NAME] # e.g. bash a2a-peer-setup.sh nas
|
||||
#
|
||||
# Requires on the box: hermes (+ A2A plugin) and tailscaled in the same tailnet.
|
||||
# Magic DNS NOT required — the published URL is the box's 100.x CGNAT address.
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
NAME="${1:-peer}"
|
||||
PORT="${A2A_PORT:-9900}"
|
||||
TOK="${A2A_BEARER_TOKEN:?run with A2A_BEARER_TOKEN=<shared token> to avoid editing this file}"
|
||||
ENVF="${HERMES_HOME:-$HOME/.hermes}/.env"
|
||||
|
||||
echo "→ enabling A2A platform + toolsets (agent_name=$NAME, port=$PORT)"
|
||||
hermes config set gateway.platforms.a2a.enabled true >/dev/null 2>&1 || true
|
||||
hermes tools enable a2a --platform a2a >/dev/null 2>&1 || true
|
||||
hermes tools enable a2a --platform cli >/dev/null 2>&1 || true
|
||||
|
||||
# Tailnet IP (works without Magic DNS); first 100.x interface as fallback
|
||||
TS_CLI="$(command -v tailscale || echo tailscale)"
|
||||
TS_IP="$("$TS_CLI" ip -4 2>/dev/null || true)"
|
||||
[ -z "${TS_IP:-}" ] && TS_IP="$(ip -4 -o addr 2>/dev/null | awk '{print $4}' | cut -d/ -f1 | awk -F. '$1==100{print; exit}')"
|
||||
[ -z "${TS_IP:-}" ] && { echo "✗ no tailnet IP found — is tailscaled running and logged in?"; exit 1; }
|
||||
PUBLIC_URL="http://${TS_IP}:${PORT}"
|
||||
|
||||
# ~/.hermes/.env — idempotent upsert (never duplicate keys)
|
||||
mkdir -p "$(dirname "$ENVF")"; [ -f "$ENVF" ] || : > "$ENVF"
|
||||
set_var() { # key value
|
||||
if grep -qE "^$1=" "$ENVF" 2>/dev/null; then
|
||||
sed -i.bak "s#^$1=.*#$1=$2#" "$ENVF" && rm -f "$ENVF.bak"
|
||||
else
|
||||
printf '%s=%s\n' "$1" "$2" >> "$ENVF"
|
||||
fi
|
||||
}
|
||||
set_var A2A_HOST "0.0.0.0"
|
||||
set_var A2A_PORT "$PORT"
|
||||
set_var A2A_PUBLIC_URL "$PUBLIC_URL"
|
||||
set_var A2A_AGENT_NAME "$NAME"
|
||||
set_var A2A_BEARER_TOKEN "$TOK"
|
||||
|
||||
echo "→ done. Public URL: $PUBLIC_URL"
|
||||
echo "→ start (or restart) the gateway in its own tmux session:"
|
||||
echo " tmux new -d -s gateway 'env TERM=xterm hermes gateway run 2>&1 | tee -a ~/.hermes/logs/gw.log'"
|
||||
echo "→ verify (from inside the box): curl -sS ${PUBLIC_URL}/.well-known/agent-card.json | head -c 200"
|
||||
echo "→ verify from ANOTHER tailnet box: curl -sS ${PUBLIC_URL}/.well-known/agent-card.json"
|
||||
echo
|
||||
echo "NOTE: other peers must now point their a2a_agents.<name>.url at ${PUBLIC_URL}"
|
||||
echo " (CGNAT-IP form) if their tailnet has no Magic DNS for the old name."
|
||||
Reference in New Issue
Block a user