gabrielvidalandClaude Opus 5.5 4d0dcfa3ff refactor(toolproxy): the tools are plugins — retire the core brokers, the guests' tool groups and the hub editions
Since 2026-11-25 nanobanana, video-extract, 3d-gen, 3d-render, matomo,
movies and meta are live plugins with their own proxies and managed grants,
but the core still served the old path next to them — and its hub editions
won over the plugin skills on workers. This finishes the move (form
ai-agent-moves-to-ai-agent-plugins_o2qxmd, move A). Rebased on 41665fa2,
which had already removed the core's Meta Business.

- gone: toolproxy/{matomo,media,webroutes,owned,catalog}.py, the nanobanana /
  3d-gen / 3d-render / video-extract / matomo / movies routes and the movies
  webhook, cli/skills/{nanobanana,3d-gen,3d-render,video-extract,matomo,
  movies}, the guests' `tools` groups (users store, Caller.tool_groups,
  Me/GuestUser.tools, tools.matomoSites), the User page's Paid tools and
  Tools budget panels
- kept: the /proxy/tools door (tokens, whoami — now the caller's plugins and
  spend — and the shared client), the tool ledger, the tools chip, a guest
  job's tool token (c6e15991: tool_scope still gives one with plugin skills)
- labsync: a plugin skill wins over a lab skill of the same name; plugin
  skills with a proxy keep their hub.json
- guest runs get their plugins' skills on spawn, resume, reply, fork and No
  project runs alike (deps passed to scope_for / scratch_scope everywhere)
- Movies brings Jellyfin when the movies grant comes on (new guest, or the
  owner's switch)
- plugins/carryover_tools.py: tool groups → grants / installs (never over an
  explicit grant), Meta keys + saved days (only where the plugin has none),
  Matomo viewers, Seerr users and pending requests, 3d-gen ownership → the
  plugins' data, once
- matomo_sites: users.json tools.matomoSites → the matomo grant's
  `extraSites` (list grantField, sibling ai-agent-plugins PR), and the grant
  on for an `analytics` guest — once per guest, so Cel (analytics + site 11
  after the groups moved) gets it; an explicit grant only gets extraSites
  when it has none; waits for a matomo manifest with the field
- Me → Budget's Tools card reads the guest's managed plugins

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 11:44:24 +01:00

ai-agent

A self-hosted agent layer for your computer — spawn and watch coding-agent sessions from an installable PWA, browse every conversation with real per-turn token costs, and manage the whole Claude context (CLAUDE.md files, skills, hooks, memories, projects) that shapes what the agent does.

Think Lovable, but open source and running on your own hardware: the agent builds things, the app shows you everything it touches — conversations, files, projects, costs, deploys — and nothing leaves your machine beyond the model API calls you configure.

Extracted from my homelab monorepo after ~280 commits; full history preserved. It runs my homelab's AI operations daily at ai-agent.lab.gabvdl.xyz.

What it does

  • Spawn / resume / interrupt agent sessions from the composer — pick a model (fetched live from the Anthropic API), an effort level, attach files — and watch the run stream into a live thread over SSE within seconds.
  • Conversation archive — every Claude Code transcript parsed into a rich thread view: per-turn token usage and dollar cost, tool cards with duration and diff stats, thinking blocks, task panels — each element with its own visibility switch.
  • Claude-context editor — every CLAUDE.md and the .claude/ tree (skills, hooks, agents, settings) as an editable file list with real token counts and per-model costs, recomputed only when content changes.
  • Catalogs — projects gallery (git history, goals, costs per project), services catalog (static compose + Traefik parsing), assistant memories, scaffolding templates, plans with estimated-vs-actual metrics.
  • Cron agents — scheduled sessions defined by a cron expression plus a prompt file; harness/model/effort declared in the prompt's frontmatter.
  • Notification hub — the source of truth for the agent's "done"/"ask" push notifications (Home Assistant integration included), with tappable answers POSTed back to the blocked session.

Architecture

┌─────────────────────────── Docker container ───────────────────────────┐
│  FastAPI backend (:8080)  ──serves──  React PWA (Vite, installable)    │
│  • transcript parser (resumable, O(new bytes) per live tick)           │
│  • SQLite store: token counts, costs, skill analytics                  │
│  • SSE hub: one event bus invalidates the UI                           │
│  • cron scheduler, notification hub, trusted-caller gate               │
└──────────────┬─────────────────────────────────────────────────────────┘
               │ POST /spawn|/resume|/interrupt (Bearer token)
        ┌──────▼───────────────┐        ┌───────────────────────────┐
        │ sidecar (runner)     │        │ worker = the same sidecar │
        │ host process — or    │        │ on another machine (Mac,  │
        │ inside the container │        │ launchd), over Tailscale  │
        └──────────────────────┘        └─────────────▲─────────────┘
          launches `claude -p …`          hub pulls: runs, /health,
          transcripts land in             /sessions, /feed (transcripts
          watched dirs                    mirrored into a watched dir)

A worker is that runner on another machine, paired once from a one-line string its installer prints; sessions there use that machine's own login and tools. The hub always calls in — the worker never contacts it (see worker/README.md).

The same sidecar/sidecar.py runs in one of two places and the backend can't tell the difference: on the host (a session then has the host user's own auth, hooks and skills — exactly a terminal session) or inside the container (RUNNER_IN_CONTAINER=1, the standalone default — the image bundles the Claude Code CLI and spawns sessions with no host process at all).

Notable engineering, hard-won on a real archive (~900 transcripts / 458 MB):

  • Resumable transcript parsing — a live session appends every couple of seconds; a ParserState per growing file is fed only the new bytes instead of re-parsing from byte 0 (O(n²) over a session, before).
  • One git walk, not one per item — both catalogs share a HEAD-keyed git log --name-only bucketed per directory. /api/services went from two git log forks per service per request (11 s) to <1 s.
  • Metadata-only list endpoints + per-file content loads + one-row SSE patches: the conversation list went 1.3 MB → 89 KB, /api/bundle 12.5 s → 26 ms, idle CPU ~58% → ~7% while a session streams.
  • Blue-green deploys — deploy.sh health-gates a standby container on /api/health, cuts the reverse proxy over, recreates, restores: zero downtime, and a bad build never touches the live container.
  • Trusted-caller security gate — the API answers only the reverse proxy, the host, or a shared token; read-only API keys allow safe methods only (a desk phone reads notifications aloud but can never spawn a session); uploaded bytes are served nosniff + attachment so user content never executes on the app origin.
  • Schema-drift canary — the Claude Code transcript format is internal and undocumented; scripts/schema-drift.py diffs a structural footprint of fresh transcripts against a committed baseline and cross-checks the real parser against raw record counts.
  • In-browser mock backend — ?mock=1 swaps fetch + EventSource for a deterministic, combinatorial in-memory seed (every UI state reachable from a cold load), so the PWA demos and tests with no backend at all.

Stack

FastAPI · Python 3.12 · SQLite (WAL) · React 18 · TypeScript · Vite · Tailwind · TanStack Query (IndexedDB-persisted) · Zustand (server-persisted) · SSE · orval (API types generated from the OpenAPI spec) · Docker · Traefik.

Run it

Standalone (no host mounts — catalogs degrade gracefully when a mount is absent):

docker compose -f docker-compose.standalone.yml up -d
# → http://localhost:8080  (set ANTHROPIC_API_KEY, or mount a logged-in
#   Claude home at the runner's $HOME, to spawn sessions)

scripts/standalone-smoke.sh boots the image against a throwaway workspace and asserts every catalog endpoint, the PWA shell and the bundled runner answer correctly.

In my homelab it runs behind Traefik + Authelia with the host-side sidecar; that deployment config (compose mounts, Traefik router, blue-green deploy.sh) lives in the homelab repo's services/ai-agent/ shim. The copies of those files in this repo's history are kept as reference.

Where it's going

See GOAL.md — the north star is the open-source, intuitive, private and secure agent layer of any computer: one container, zipgo-backed hosting, in-container self-update.

S
Description
No description provided
Readme
92 MiB
0 Stars 1 Watchers 0 Forks
Languages
Python 55.5%
TypeScript 43.1%
Shell 0.6%
JavaScript 0.4%
CSS 0.3%
Other 0.1%