feat: HTTP quota and session-status endpoints for remote clients - #59
Merged
Conversation
- GET /api/quota on the hub queries accountUsageStats directly (machine-level
concern, no ACP round-trip) with a 30s TTL cache and in-flight dedupe
- bridge GET /status (in-memory pendingTurns derivation, no backend RPC)
byte-proxied by the hub at GET /api/instances/{id}/status
- heartbeat sessions[] carries a coarse status field; hub validSessions
passes valid values through and strips invalid ones
- docs: REMOTE-CLIENTS endpoints/chapters, ARCHITECTURE summary, ADR-0005
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Remote clients (the mobile app) had to open a full ACP WebSocket — connect,
initialize, request, disconnect — to read account quota or per-session running status. Both are poor fits for the session protocol: quota is account-level (the machine's credentials, not any session/instance), and running status is a polling concern, not a stream.Changes
GET /api/quota(hub): queriesaccountUsageStats()directly — the same function behind the/quotacommand and theaccount/usage_statsACP method — with a ~30s TTL cache plus a single in-flight slot so polling can't hammer the upstream. Response body is identical to the ACP method's result, so clients reuse one parser. The ACP method stays for attached editors.GET /status(bridge loopback, newsrc/remote/status-endpoint.ts): pure in-memory assembly —sessionSummariesmembership +pendingTurnsderivation (sameturnActivelogic assession/load), no backend RPC, safe to poll at 1–2s.GET /api/instances/{id}/status(hub): byte-level proxy to the bridge route, same pattern and error semantics as/fs(401 / 404 unknown instance / 502 unreachable).statusfield:sessions[]entries carry a coarserunning | idle; hubvalidSessionspasses valid values through and strips invalid ones. Compatible both directions (older hub drops the field; older bridge omits it).REMOTE-CLIENTS.md, architecture summary, anddocs/adr/0005-http-quota-and-status-endpoints.mdrecording why the hub queries quota directly (machine-level concern, must answer with zero bridges alive; version drift covered by the existing self-upgrade handshake).Out of scope (noted in the ADR as additive extensions):
waiting_permissionstatus, background-task details.Test plan
pnpm typecheck,pnpm lint, full suite green (644 tests, +17 new)