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
feat(usage): expose per-account vicoop-codex usage via the bridge (#360)
Add an admin/owner-only API to read a connected vicoop-codex agent's
per-account Codex usage through the bridge server.
The usage data lives on the client (vicoop-codex `serve`'s GET /usage), so a
minimal request/response RPC is layered over the WS protocol:
- protocol: `usage.request` (Down) + `usage.response` (Up), correlated by
requestId; `usage` payload is opaque (z.unknown), forwarded verbatim.
- client: `Backend` gains an optional `usage()`; the vicoop-codex backend
implements it by GETting its serve `/usage` (read-only, no quota cost). The
client answers `usage.request` with `usage.response` (ok | unsupported |
usage_failed).
- server: `usage-rpc.ts` correlates request↔response (offline/timeout/error,
with a responding-agent id-binding guard); `ws.ts` routes `usage.response`;
new `GET /admin-api/agents/:id/usage` is owner-session authed and allowed
only for the bridge admin (`isAdmin`) or the agent's owner
(`conn.ownerPrincipal`), and only for the `vicoop-codex` backend. Errors map
to 404 (not found/unauthorized), 400 (wrong backend), 503 (offline),
504 (timeout).
Tests: usage-rpc correlation (offline/success/error/timeout/id-binding/stale);
client dispatch (ok/unsupported/usage_failed); vicoop-codex usage() GET + error.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
vicoop-codex backend: report per-account Codex usage to the bridge on request. The client answers the new `usage.request` frame by querying its local `vicoop-codex serve``/usage` endpoint, which backs the server's admin/owner-only `GET /admin-api/agents/:id/usage` API.
0 commit comments