Skip to content

feat(telemetry): host-agent telemetry — folder watcher, Claude Code OTel, forwarded to n8 - #317

Merged
kordless merged 43 commits into
canaryfrom
feat/host-agent-telemetry
Oct 12, 2026
Merged

kordless merged 43 commits into
canaryfrom
feat/host-agent-telemetry

Conversation

@kordless

@kordless kordless commented Oct 8, 2026

Copy link
Copy Markdown

Telemetry for agents running directly on the host (Claude Code, agy, …), not inside n8 containers. Agreed design: Hyperia's sidecar collects it and keeps the last hour locally for proto_viz Live, and n8's gateway is the server of record (with lume behind it).

Pieces

  • Forwarder (`host_telemetry/forward.rs`):
    • Queues n8-schema events per pane (`agent_id: hy-`, stamped `id`/`ts`).
    • Posts to the gateway's `POST /telemetry/ingest` (nemesis8#157) in batches within its limits (1000 events / ~1 MiB).
    • Authenticates with the gateway token from the OS keyring, the same entry `n8.rs` uses.
    • 400 drops the batch and 413 splits it. Anything else (401, 404 from a gateway without the endpoint yet, 5xx, no answer) keeps the events buffered and backs off: at most 20k events, oldest dropped first.
    • `HYPERIA_N8_GATEWAY` overrides the address.
  • Folder watcher (`host_telemetry/watcher.rs`, `notify`):
    • Which panes: every 5s, panes the classifier calls an agent other than n8 (n8's monitor covers those) get their working folder watched. The folder must be a real project folder: at least 2 levels deep and not the home folder or above.
    • Skipped: `.git`, `target`, `node_modules`, `dist`, `build`, venvs and dot-folders, plus temp, swap and nuts-files temp files.
    • Coalescing: a path's raw events within 700ms become one change, and a file being written continuously still reports at least every 3s.
    • Limits: at most 200 events per pane per 5s. A shared folder is credited to one pane.
    • Output: local FileOp, and n8 `fs` with size and delta bytes.
  • Claude Code OpenTelemetry (`host_telemetry/otlp.rs`):
    • Routes: `POST /otel/v1/logs|metrics` (OTLP http/json), next to `/api/telemetry/event` with the same access rules.
    • `api_request` → local Tokens. Not forwarded until the token fields are agreed with n8.
    • `tool_result` for Edit, Write, MultiEdit and NotebookEdit → local Edit and n8 `edit`.
    • Pane from the `hyperia.pane` resource attribute; protobuf gets 415; prompts and tool content are never logged.
  • Pane env (`app/utils/agent-telemetry-env.ts`):
    • Every pane gets Claude Code's OTel settings: enable, http/json to `127.0.0.1:/otel`, tool details on, 5s export, and `hyperia.pane` appended to `OTEL_RESOURCE_ATTRIBUTES`.
    • Gated by `agentTelemetry` (default on).
    • Nothing is added if the user already exports OTLP anywhere, and no variable they set is overridden.
    • Caveat: the standard `OTEL_*` variables also apply to other OpenTelemetry SDK apps run in a pane. Those would export to the sidecar, which ignores what it doesn't recognise. If you rely on a default-port collector without setting an endpoint, set `agentTelemetry: false` or set the endpoint explicitly.

Harness

  • Port: the sandbox sidecar moved to 9811. 9801 is n8's gateway, which outlives Hyperia, so the harness couldn't start while n8 was up.
  • Stand-in gateway: every launch points the sandbox at a stand-in n8 gateway on 127.0.0.1, so a sandbox never forwards to the real one.
  • s15:
    • A fake `claude.exe` edits files in a sandbox project.
    • Checks the pane's OTel env and the watcher's FileOps (6), a Claude OTLP batch (1200 tokens plus an Edit), and that `fs` and `edit` reached the gateway as `hy-` with a bearer token.
  • s13: fixed to use the newest web view.
  • Result: 15/15 pass, including s14 (the reconnect replay from fix(bridge): a sidecar reconnect no longer wipes what each pane is running #315), which is now runnable.

Tests

  • Sidecar `host_telemetry`: 18 pass, covering the forwarder (batching, limits, status handling, stamping), the watcher (pane rule, folder rule, exclusions, coalescing, steady writes, cap, ownership, a real temp-folder watch) and the OTLP mapping.
  • JS: 373 pass. tsc and eslint are clean.
  • Full sidecar suite: only the same 6 known failures (5 TTS tests that need `HYPERIA_MISAKI_DIR`, plus one flaky MCP session test).

Depends on

nemesis8 #156 (merged) and #157 (the ingest endpoint). Until the running gateway has #157, forwards get 404, are kept, and are retried. Nothing is lost while the Live view works locally.

🤖 Generated with Claude Code

Kord Campbell and others added 30 commits October 8, 2026 00:31
host_telemetry::forward queues n8-schema events per pane (agent_id
hy-<pane-uid>, stamped id/ts) and posts them to the gateway's
POST /telemetry/ingest in batches within its limits (1000 events /
~1 MiB), authenticated with the gateway token from the OS keyring (as
n8.rs already does). 400 drops, 413 splits, anything else (401, 404 for
a gateway without the endpoint yet, 5xx, no answer) keeps the events
buffered (bounded, oldest dropped first) and backs off. Started with the
sidecar. Sources (folder watcher, Claude Code OpenTelemetry) follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The n8 gateway listens on 9801 and keeps running after Hyperia closes, so
the harness refused to start whenever n8 was up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lets tests (and a relocated gateway) point the forwarder elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two sources for agents running directly on the host (not in n8), both
recorded locally for proto_viz Live and forwarded to the n8 gateway:

- Folder watcher (host_telemetry/watcher.rs, notify crate): every 5s,
  panes the classifier calls an agent other than n8 get their cwd
  watched (a real project folder: >=2 levels deep, not home or above).
  Skips .git/target/node_modules/dist/build/.next/__pycache__/venvs and
  dot-dirs, temp/swap/nuts-files temp files; coalesces a path's raw
  events over 700ms into one created/modified/removed decided from the
  settled file; caps 200 events / pane / 5s. Shared folders go to one
  pane. Emits FileOp locally and n8 `fs` (size/delta bytes).
- OTLP http/json receiver (host_telemetry/otlp.rs): POST /otel/v1/logs
  and /otel/v1/metrics beside /api/telemetry/event (same posture).
  Claude Code api_request -> local Tokens (not forwarded until n8's token
  fields are agreed); tool_result for Edit/Write/MultiEdit/NotebookEdit
  -> local Edit and n8 `edit`. Pane from resource attr hyperia.pane;
  protobuf -> 415. No prompt or tool content is logged.
- Every pane gets Claude Code's OTel env (enable, otlp http/json to
  127.0.0.1:<port>/otel, tool details, 5s export, hyperia.pane appended
  to OTEL_RESOURCE_ATTRIBUTES), gated by config agentTelemetry (default
  on). Nothing is added if the user already exports OTLP anywhere, and
  no variable they set is overridden.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… gateway

- The watcher's coalescer was a pure 700ms debounce, so a file written
  more often than that (a log, a long generation) reported nothing until
  it stopped. Pending paths now also flush after 3s (MAX_HOLD).
- Harness: every launch points the sandbox at a stand-in n8 gateway on
  127.0.0.1 (HYPERIA_N8_GATEWAY), so a sandbox never forwards to the real
  gateway. New s15: a fake claude.exe edits files in a sandbox project;
  checks the pane's OTel env, the watcher's FileOps, a Claude OTLP batch
  (tokens + Edit), and that fs/edit reached the gateway as hy-<pane> with
  a bearer. s13 picks the newest web view (s12's sits in a background
  tab). Full harness: 15/15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… drag

Runs the real n8.exe (agy) in a sandbox pane with the user's n8 home,
prints a tall answer, drags the window size in a burst, and checks the
pane's screen still shows it. Needs HARNESS_AGY=1 (real login, a real
container it removes afterwards). Passes today: the blank-pane reports
don't reproduce from a resize alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…changing them

Every file touched in the window (edits from agent tools and the host
watcher's writes/creates/deletes/renames) becomes a node inside the
ring, sized by its number of changes and coloured by its latest one. It
keeps the sunflower-spiral slot it got when first seen, so nodes don't
jump; new files spiral outward (60 most recent). A thread runs from each
file to every pane that touched it, coloured by that pane's latest
change and thickened by count; a new change sends a spark pane → file.
Busiest files are labelled (no overlaps). Click a file to select it:
its threads light up, the rest dims, and the callout shows its path,
change count, last change, lines and the panes behind it. Selecting a
pane highlights its files. Live/History and zoom/pan apply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Synthesized with WebAudio (no audio files):
- new comms: an electric zap (noise crackle + falling tone), pitched by
  type; a denied approval is a low buzz
- file change: a short blip, pitch by kind (create high, edit/write mid,
  rename low-mid, delete low)
- a new node on the ring: a soft two-note chime
- selecting: a quiet tick
Only for new events (the first load is silent), rate-limited per sound
and 14/s overall, silent while the tab isn't visible, with a ♪ on/off
toggle in the header remembered per browser. Any click unlocks audio if
the browser held it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dir hubs sit on a slowly turning sphere; each dir's files orbit it on its
own tilted axis, with perspective depth. Click a hub to light its files
and threads. Deep dirs fold into their parent past 16 hubs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sidecar meters each pane's PTY output (outBps, outLps, outSecsAgo in
/api/status). proto_viz shimmers a working pane's name and scrolls an arc
inside the ring at its line rate.

The stale-binary handover on second-instance now runs only when packaged:
a dev version never matches package.json, so electronmon restarts looped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read FileOps join the file view (not stats or bars): a pane that only read
a file gets a dim dotted thread, read-only files are grey, no spark/sound.
Dir labels that collide get one more path segment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every /api/tts transmission is logged as it goes on air (from, to, summary,
transcript, voice, engine, waveform peaks) with its audio under
~/.hyperia/radio; /api/radio/log and /api/radio/audio/{id} serve them,
local-only. proto_viz radiates waves and a waveform halo from the sender
while it plays, shows an ON AIR banner, and lists transmissions with the
summary and a replay button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dirs form a real tree: every folder on a file's path, single-child chains
merged, so shared parents (crates/) are junctions linking their children.
The tree branches outward in 3D; selecting a dir lights its subtree.

Double-click a file to edit it: modal with tabs and a close X, line
numbers, highlighting, find/replace, go to line, indent/comment keys.
Saves are atomic and conflict-checked against the mtime opened; outside
changes reload a clean tab and warn on a dirty one.
/api/files/{open,save,stat} are local-only, same-origin, JSON-only, and
limited to paths Hyperia's telemetry saw an agent touch (n8 /workspace
paths map to the pane's cwd).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces the dashed output arc inside the ring: a halo encircles a working
pane's name, its glow pulsing with output volume and two arcs spinning
fast while it prints (faster with more lines/s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Markdown)

A Rendered/Edit toggle (Ctrl+Shift+V) in the file editor. The sidecar
renders the buffer with pulldown-cmark, raw HTML shown as text and
javascript:/data:/file: URLs dropped; the page shows in a sandboxed frame
(no scripts) under a strict CSP. It re-renders as you type and when an
agent rewrites the file, keeping the scroll position.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
File events lived only in memory (last 300), so every sidecar restart
emptied proto_viz's file view and the editor's touched-path list. They're
now appended to ~/.hyperia/telemetry/file-events.jsonl and reloaded at
start (last 1500 in memory; the journal trims itself past 20k lines).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The header refocused the terminal on every mouseup, so finishing a
drag-select (or a click to place the caret) in the tab rename box blurred
it, and the blur submitted the rename. Mouseups from text fields are left
alone now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The centre file tree in Live mode keeps only files touched in the last
15 minutes, so it stays current; stats keep the hour and History its range.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each agent pane hertz-radio is approved to message gets a random two-word
NATO call sign (OS CSPRNG). While hertz is running and has just heard a
transmission (5 min), the sign shows as a gold badge top-right of the
pane. hertz-radio (only) can list signs (radio_callsigns) and deliver by
sign (radio_deliver); delivering rotates that pane's sign at once, so a
sign heard on air or replayed never works twice. The sidecar watches
hertz's /events stream for running/heard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ag to tip

The agent ring is now a floor disk under one perspective camera; the file
tree grows up from it (always above the plane) and threads drop to the
agents. Drag moves around the floor, Ctrl+drag tips and orbits, double-
click resets. 3D/2D buttons switch between the tilted view and straight
down. Clicks hit-test in screen space (files, dirs, agents, names).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A sounding transmission's saved audio is decoded once; an FFT at the
playhead gives 32 log-spaced bands (80 Hz-8 kHz) and loudness. The halo
round the sender is the mirrored spectrum, the rings scale with loudness,
and the ON AIR / REPLAY banner shows live spectrum bars over the timeline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When an agent sends input to a plain terminal (terminal_run / pane_send),
the host watcher also watches that terminal's folder for 30 minutes after
the last drive, so the files a build or script it runs touches show up in
proto_viz, threaded to that terminal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ring angles came from a node's rank in a list sorted by kind, so an agent
whose foreground process briefly changed (a tool subprocess) flipped kind
and jumped, and any node arriving or leaving shifted everyone. Each node
now keeps a slot; new ones take a free slot, a departed one's slot is held
for 10 minutes, and the ring compacts (order kept) only when a third is
empty. A pane seen running an agent stays an agent for 10 minutes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent detection used only the foreground process, so a pane whose agent
was running a tool read as a plain terminal (blue). It now also checks the
pane's app and launch command. Ring nodes keep their stable order but are
spaced evenly over the live ones; held slots for departed nodes had left
the live names bunched on one side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ecar restart

/api/status now carries each pane's splitLabel; with the tabId the dashboard
works out the pane's tint the way term.tsx does (root uid hash + split
letter over the four theme tints), and names, halos and chips use it.

The sidecar saves pane names (~/.hyperia/pane-names.json) and restores one
when the app re-registers a pane without it, which it does after every
sidecar restart (names showed as short pane ids).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…et streams

Each container pane n8 reports traffic for is wired to a NET hub floating
above the floor. The link thickens with throughput; packets stream down
(received, cyan) and up (sent, amber) at a rate following its bytes/s, its
rates sit at the foot of the link, and the hub glows with the total.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rendered view showed raw HTML as text, so a README's <div align=center>
came out literally. Markdown output now goes through ammonia with an
allow-list (README tags and align; http/https/mailto URLs only; no scripts,
handlers or styles), still inside the sandboxed, CSP-locked frame.

Links: headings get GitHub-style ids and #anchors scroll the preview;
relative links open that file in a new editor tab; http(s)/mailto open
outside. (They opened nothing before: a sandboxed _blank.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The runtime (docker or podman) is a blue globe a tenth of the floor's
diameter, hanging just below the NET hub with a straight uplink to it.
Received traffic drops down the uplink into the marble's centre, then
branches out to each container; sent traffic runs the other way. The
marble's glow follows total throughput; its label names the runtime and
how many containers are live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bigger floor

Each pane gets a translucent slice of a band from the floor's edge out past
the names, in its own Hyperia colour, with a coloured rim on the outside
and its tab's name on the rim. The ring is ordered by tab (tab-bar order)
then split letter, with a small gap between tabs, so a tab's panes sit
together (and stay put). The floor is ~15% larger by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kord Campbell and others added 12 commits October 9, 2026 17:50
…creens)

Each terminal pane gets a small CRT standing at the outer rim of its band
slice: rounded bowed glass in a bezel, a stand down to the band, showing
the pane's live screen text (/api/screen, every 2 s) tinted in its colour
with scanlines and a vignette. Far ones draw first and dimmer. The header
'screens' button turns them off (remembered).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One larger CRT at the selected pane's slice instead of one per pane; only
that pane's screen is fetched, right away on select and every 2 s after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A blank screen (an idle pane since a sidecar restart, e.g. Precise
Aardvark) falls back to its recent scrollback instead of showing nothing.
Double-clicking the screen opens a read-only terminal view, like the
editor: live screen or the last 500 lines of scrollback, refreshed every
second, kept at the bottom unless you scroll up; Esc/X/backdrop closes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d and bigger

Replaces the full-screen window. The pane's CRT flies off the rim, squares
up to the view and holds still at the top (about half the view wide),
redrawn sharp at that size with the whole screen fitted; the scene keeps
turning below and a tether runs to the pane's slice. Esc, double-clicking
it, or selecting another pane sends it back to the rim. The rest of the
view stays clickable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Instead of lifting the monitor out of the scene, the camera goes to it:
swings round so the pane's monitor is in front, tips down to face it and
zooms until it fills ~80% of the view, centred; then it rides the ring's
rotation so the monitor stays square and still. The focused monitor draws
last and sharp at that size. Esc or double-click flies the camera back to
your orbit, tip and zoom; drag/wheel are held while focused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to leave

- The whole band slice, out to the name, selects its pane; hovering it
  shows that pane's monitor (it stays while the pointer is on it).
- Clicking the monitor flies the camera in: from the live turning view
  into a computed end shot (monitor in front, faced square, ~80% of the
  view) on one eased curve, zoom eased in log space; no chasing target.
- There it's pinned and the camera lets go, so the ring keeps turning
  below, with a tether to the pane's slot. Any click flies back out to
  where the rotation would be now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mail notices to the pane the human has focused are held while Hyperia is
the foreground app. The sidecar learned that only from window focus/blur
events and assumed 'in front' when it knew nothing, so after a sidecar
restart (or a missed blur) it held the focused pane's notices indefinitely
while the human was in another app. It now assumes 'elsewhere' until told,
and once the app sends AppFocus heartbeats, a missing one means elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A few KB/s of keepalive chatter drew a thick link and ~11 packets/s, so an
idle container looked busy. Now: under ~4 KB/s a faint link and a slow
trickle; the link is full at ~1 MB/s; packets climb from ~4 KB/s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sidecar learned whether Hyperia is the foreground app only from window
focus/blur events, so one missed blur (or a sidecar restart) left it
thinking the human was in Hyperia and held the focused pane's mail
notices while they were in another app. The app now re-sends its real
state (BrowserWindow.getFocusedWindow) every 2 s as a heartbeat; the
sidecar treats a missing heartbeat as 'elsewhere'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e via I/O)

Only n8 containers reported network. Host agents (a Claude in a pane) now do:
- proxy.rs: a CONNECT-only counting proxy on 127.0.0.1 (sidecar port + 13)
  that relays HTTPS untouched and counts bytes per pane (pane uid as proxy
  username); agent panes get HTTPS_PROXY/NO_PROXY (agentProxyEnv; a user's
  own proxy wins; agentNetworkProxy: false turns it off). Exact, new panes.
- netio.rs: every 3 s, each host agent pane's process-tree I/O counters
  (GetProcessIoCounters: file + network) as an approximation, for panes not
  on the proxy.
- proto_viz: host agents link straight to the NET hub (no Docker marble),
  dashed and marked ~ when approximate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A host agent running a tool flips its pane's foreground to bash/pwsh, so
refresh() dropped its call sign and issued a new one moments later; the
gold badge kept changing under the human reading it. A sign now survives
up to 120 s of a pane not looking like an agent (keep_sign); a revoked
hertz-radio grant or a closed pane still drops it at once. Unit-tested
without a Bridge (apply_refresh).

Written by Secure Yak (n8 OpenCode pane, pairing), reviewed by host-claude.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kordless
kordless merged commit bda8e3c into canary Oct 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant