You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Problem
I track token usage across AI tools with agentsview, and lately I've
been
running more remote agent tools on machines other than my primary dev
box.
Each of those machines records its own sessions locally. The Postgres
support
(`pg push` / `pg serve`) already lets me review everything together, but
keeping the shared database current meant either remembering to run `pg
push`
by hand on each machine or wiring up a bespoke cron job per host. I
wanted a
touchless way to sync data from multiple machines into one place so
remote
agent token usage shows up in my primary dashboard automatically,
without
maintaining custom cron entries everywhere.
I also made some updates to hermes specific code because although tokens
were being passed through, the associated costs were not being
aggregated
properly.
## pg push service
A long-running auto-push daemon and a first-class way to install it as
an OS
service, so a recorder machine keeps the shared Postgres current on its
own.
**`agentsview pg push --watch`** start a foreground daemon that pushes
to Postgres
shortly after sessions change, with a periodic floor as a safety net:
- A file watcher (reusing the same machinery as `serve`) coalesces
change
events over a debounce window (`--debounce`, default 30s) and triggers a
local sync + incremental push.
- A periodic floor (`--interval`, default 15m) pushes regardless of file
events and covers any directories the watch budget couldn't cover.
- Pushes are serialized by a single goroutine and connect to Postgres
lazily,
reconnecting on error. A transiently unreachable database is logged and
retried on the next trigger rather than crashing the daemon.
- A single-instance lock prevents two watchers from racing on the push
watermarks. On shutdown (SIGINT/SIGTERM) it performs one bounded final
flush.
- It reads the same `[pg]` config and project filters as `pg push`, and
honors `result_content_blocked_categories` so the push path no longer
diverges from `serve`.
**`agentsview pg service install|uninstall|status|start|stop|logs`**
installs and manages the daemon as a per-user OS service:
- launchd LaunchAgent on macOS, `systemd --user` unit on Linux, behind a
small
platform abstraction with pure (golden-tested) unit-file rendering.
- `install` validates that the Postgres DSN is resolvable before
creating the
service, and surfaces the systemd linger requirement so the service
keeps
running on headless boxes after logout.
- `status` reports the manager state plus the last successful push time;
`logs -f` tails the daemon log and survives log rotation.
The daemon reads the DSN from the existing config file (no credentials
are
copied into unit files), so protecting `config.toml` is sufficient.
## Notes
- Platform support targets macOS (launchd) and Linux (`systemd --user`);
the
daemon command itself is cross-platform Go.
- The generated unit always pins `AGENTSVIEW_DATA_DIR` to the
install-time data
dir, so the service resolves the same config regardless of the
environment it
starts in.
- The watch daemon's initial resync is push-oriented and skips the
serve-side
`Vacuum`/`BackfillSignals` steps, since signal recomputation happens on
the
serve side.
- A windows service was not added because I don't currently have access
to a
windows machine that I could use for testing.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments