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
{{ message }}
Repository navigation
Commit c132f00
Browse filesBrowse the repository at this point in the historyBrowse files
feat: add /admin/stats endpoint with persistent runtime counters (#106)
Exposes GET /admin/stats returning running totals for
requests served, upstream prompt/completion/total tokens, emails
hidden by the sender policy, and a per-address breakdown of filtered
senders.
Copy file name to clipboardExpand all lines: README.md
+11-2Lines changed: 11 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,12 +49,21 @@ ClawShell supports OAuth-based authentication as an alternative to static API ke
49
49
-**Automatic Token Refresh**: Access tokens are refreshed transparently before they expire.
50
50
-**Request Translation**: Automatically translates OpenAI Chat Completions API requests to the ChatGPT Responses API format when using Codex OAuth.
51
51
52
-
### 5. Seamless Integration
52
+
### 5. Runtime Statistics
53
+
54
+
ClawShell exposes running counters at `GET /admin/stats` so operators can audit proxy activity since startup and across restarts.
55
+
56
+
-**What's Counted**: Total requests served, total upstream `prompt_tokens` / `completion_tokens` / `total_tokens` (parsed from non-streaming JSON responses — SSE streams are not counted), number of emails hidden by the sender policy, and a per-address breakdown of filtered senders.
57
+
-**Loopback-Only**: The endpoint is reachable without a virtual key but only from `127.0.0.1` / `::1` peers; non-loopback clients receive `403`.
58
+
-**Persistent**: Counters are flushed to disk every 30 seconds and on graceful shutdown. The location is a required config field — set `[stats] persist_path = "..."` in `clawshell.toml` (typically `/var/lib/clawshell/stats.json` under the hardened systemd unit, since `/etc/clawshell` is read-only there).
59
+
-**Bounded**: The filtered-address map is capped at 10,000 unique entries; further unique addresses are aggregated under an `<overflow>` bucket so memory stays bounded.
60
+
61
+
### 6. Seamless Integration
53
62
54
63
-**Drop-in Sidecar**: The `clawshell onboard` wizard configures exactly one downstream LLM client per run — either OpenClaw or [Hermes Agent](https://github.com/NousResearch/hermes-agent) — to route all requests through ClawShell's proxy. See [Agent Target (pick one)](#agent-target-pick-one).
55
64
-**No External Dependencies**: Uses Unix file system permissions to protect secrets. No IdP, Vault, or external key management service required.
0 commit comments