Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ systemd and Hermes Desktop keep supervising it; chats running on that process st
| Wiki | Connect a folder of Markdown notes and read or edit it from the app, using your Hermes login. | [Wiki](docs/NATIVE_WIKI.md) |
| Group chat activity | See which tools each agent in a group chat is using, live. Needs a Hermes host with the `on_room_member_activity` hook. | [Room activity](docs/NATIVE_ROOM_ACTIVITY.md) |
| Context usage | How much of the model's context the last request used. | [Context usage](docs/CONTEXT_USAGE.md) |
| Provider usage | How much of each AI plan or balance you've used: Claude, Codex, GitHub Copilot, OpenCode, OpenRouter, DeepSeek, Nous Portal and more. Found automatically from the tools installed on the computer and the providers set up in Hermes. Read-only. | [Provider usage](docs/PROVIDER_USAGE.md) |
| Generated media and files | Agent-made images, videos and files show up in chat. Hermes' own media rules decide what can be shared, and host paths are never exposed. | [Agent attachments](docs/AGENT_ATTACHMENTS.md) |
| Model names | `model-names.json` gives friendly model names. The app can refresh it without a plugin update. | |

Expand Down
72 changes: 72 additions & 0 deletions docs/PROVIDER_USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Provider usage

bighelp can show how much of each AI plan or balance you've used, for the tools on your Hermes computer.
The plugin finds them on its own: coding tools installed on the computer, and providers set up in Hermes.
Nothing to configure.

## What it reads

| Tool or provider | Found when | Where the numbers come from |
| --- | --- | --- |
| Claude | Claude Code is installed or signed in, or Hermes has a Claude sign-in | Claude's usage service (the same numbers as `/usage` in Claude Code): 5-hour session, week, per-model weeks, extra usage |
| Codex | The Codex CLI is installed, or Hermes has a Codex sign-in | The Codex CLI's own app server (`account/rateLimits/read`), or Hermes' `/usage` for its own sign-in: session and weekly limits, credits, banked resets |
| GitHub Copilot | The Copilot CLI or GitHub CLI is installed, or Hermes has a Copilot token | GitHub's Copilot usage (monthly credits or premium requests); the Copilot CLI's `account.getQuota` as a fallback (rounded, marked approximate). Same approach as [ghc-usage-hermes](https://github.com/promptclickrun/ghc-usage-hermes) |
| Google AI Studio | Hermes has a Gemini API key, or Gemini CLI is installed | Google has no usage API for AI Studio keys. The plugin checks that the key works and links to AI Studio's usage page |
| OpenCode | The OpenCode CLI is installed, or Hermes has an OpenCode Go or Zen key | `opencode stats` (cost, sessions and tokens for the last 7 and 30 days); OpenCode Go limits through Hermes |
| OpenRouter | Hermes has an OpenRouter key | OpenRouter's `/key` and `/credits`: balance, key limit, spend today, this week, this month |
| DeepSeek | Hermes has a DeepSeek key | DeepSeek's `/user/balance` |
| Nous Portal | Hermes is signed in to Nous Portal | Hermes' Nous Portal account: monthly credits, top-up credits |
| Other Hermes providers | A Hermes provider plugin implements `fetch_account_usage` and has a key | That plugin's own usage hook |

The provider Hermes chats with is listed first and marked.

## Read-only

- **Logins borrowed from other tools are never refreshed or rewritten.** If Claude Code's sign-in has expired,
bighelp says to open Claude Code once. Hermes' `auth.adopt_external_logins: false` also turns off reading
Claude Code's login here.
- CLIs run with fixed arguments, no shell, and a time limit, and refresh their own logins the way they always do.
- Keys and tokens are only sent to their own provider, and never across a redirect. They, and account emails,
names and IDs, never reach the app.
- Results are cached for five minutes. Pull to refresh skips the cache, but not more than once every 15 seconds.
Each provider gets 20 seconds; a slow one shows "took too long" instead of holding up the rest.

## For the app

`native-provider-usage-v1` in `/native/context` features.

`POST /api/plugins/loopdy/native/usage/list` with the usual native headers (`If-Match` context ETag and
`X-Loopdy-Request-ID`) and body `{"agentId": "default", "refresh": false}`. Hermes lookups use that profile.

```json
{
"agentId": "default",
"fetchedAt": "2026-09-27T20:00:00Z",
"cached": false,
"providers": [
{
"id": "claude",
"name": "Claude",
"status": "ok",
"message": null,
"plan": "Pro",
"detectedVia": ["cli"],
"activeInHermes": true,
"windows": [
{"label": "Session (5 hours)", "usedPercent": 42.0, "resetsAt": "2026-10-02T18:00:00Z", "detail": null}
],
"facts": [{"label": "Balance", "value": "$25.00"}],
"manageUrl": "https://claude.ai/settings/usage",
"approximate": false
}
]
}
```

- `status`: `ok`, `signInNeeded`, `notShared` (the provider doesn't publish usage for this kind of login), or
`error`. Anything but `ok` has a plain `message` to show.
- `windows` are limits with a percentage used (show as bars). `facts` are label and value pairs, already formatted.
- `detectedVia`: `cli` (a tool on the computer) and/or `hermes` (set up in Hermes).
- `id` is stable: `claude`, `codex`, `codex-hermes` (only when Hermes uses a different ChatGPT account than the
Codex CLI), `copilot`, `gemini`, `opencode`, `openrouter`, `deepseek`, `nous`, and `hermes-<provider>`.
- Times are UTC, whole seconds, ending in `Z`.
1 change: 1 addition & 0 deletions docs/SECURITY_AND_PRIVACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ current code. It isn't legal advice or an independent audit.
| Live voice audio | Not stored | Flows directly between your phone and the voice provider |
| Notification content | Pending events under `plugin-data/loopdy/managed-notifications/` | Sealed for your phone with current app builds; see below |
| Context usage | Token counts only, no text | To the app |
| Provider usage | Cached in memory for five minutes | Keys go only to their own provider; usage numbers (no keys, emails or account IDs) go to the app. See [Provider usage](PROVIDER_USAGE.md) |

All plugin data lives under the active Hermes profile home in `plugin-data/loopdy/`, with owner-only
permissions. Nothing is sent to bighelp except notifications you turned on.
Expand Down
2 changes: 1 addition & 1 deletion loopdy_plugin/link_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def parse_direct_enrollment(payload: dict[str, Any]) -> dict[str, Any]:
"body_fat_percentage",
"workout",
)
PLUGIN_VERSION = "2.17.0"
PLUGIN_VERSION = "2.18.0"
AVAILABLE_WIKI_OPERATIONS = available_wiki_operations()
GROUPS_OPERATIONS = frozenset(
{
Expand Down
32 changes: 31 additions & 1 deletion loopdy_plugin/native_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Finite stock-serve HTTP adapters for existing Loopdy domain services."""
from __future__ import annotations

from contextlib import asynccontextmanager
from contextlib import ExitStack, asynccontextmanager
import json
import logging
import re
Expand Down Expand Up @@ -430,3 +430,33 @@ async def board_approvals(request: Request) -> Response:
@router.post("/board/identity")
async def board_identity(request: Request) -> Response:
return await _board_request(request, _Body, "identity", _BOARD_LIST_BYTES)


class _Usage(_Body):
refresh: StrictBool = False


def _usage_for_profile(agent_id: str, refresh: bool) -> dict:
from .provider_usage import usage
from .workspace_capabilities import profile_scope
with ExitStack() as stack:
try:
stack.enter_context(profile_scope(agent_id))
except ValueError:
raise NativeAPIError(404, "profile_not_found", "The selected profile no longer exists.") from None
return usage(agent_id, refresh=refresh)


@router.post("/usage/list")
async def provider_usage(request: Request) -> Response:
"""Usage and limits for the AI tools and providers on this host (bighelp app: Usage)."""
from .provider_usage import CAPABILITY
owner = native_context(request)
request_id = _precondition(request, owner)
if CAPABILITY not in owner.features:
raise NativeAPIError(503, "usage_unavailable", "Usage isn't available on this host.")
body = await _body(request, _Usage)
value = await run_in_threadpool(_usage_for_profile, body.agentId, body.refresh)
if native_context(request) != owner:
raise NativeAPIError(412, "context_changed", "The native context changed; refresh before retrying.")
return _response({"agentId": body.agentId, **value}, owner, request_id)
5 changes: 5 additions & 0 deletions loopdy_plugin/native_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,9 @@ def skip(feature: str, reason: str) -> None:
features.append(restart_capability)
else:
skip(restart_capability, "in-place restart needs a POSIX host.")
from .provider_usage import CAPABILITY as usage_capability, available as usage_available
if usage_available():
features.append(usage_capability)
else:
skip(usage_capability, "public profile helpers are unimportable.")
return profile, tuple(features)
Loading
Loading