Skip to content

Add Hermes Agent provider#386

Open
iquantecho wants to merge 9 commits into
getagentseal:mainfrom
iquantecho:feat/hermes-provider
Open

Add Hermes Agent provider#386
iquantecho wants to merge 9 commits into
getagentseal:mainfrom
iquantecho:feat/hermes-provider

Conversation

@iquantecho
Copy link
Copy Markdown

Hey! I added Hermes Agent support to CodeBurn because I wanted to use it with my own Hermes sessions, and figured I’d share it in case it’s useful here too. No pressure at all if this isn’t the direction you want to take it.

Summary

  • Adds a Hermes Agent provider that reads session-level usage from Hermes SQLite state databases.
  • Discovers both root and profile Hermes databases.
  • Tracks input, output, cache read/write, reasoning tokens, stored costs, tools, shell commands, and inferred projects.
  • Includes fixture-style provider tests for normal, legacy, root/profile, tool mapping, and path parsing cases.

Testing

  • npm test -- tests/providers/hermes.test.ts

I also checked it against my real local Hermes data before opening this.

Closes #368

- Add Hermes Agent feature entry under Added (CLI) in CHANGELOG
- Map delegate_task → Agent, vision_analyze → Vision, process → Bash,
  browser_get_images → Browser, skills_list → Skill
- Add comment explaining composio MCP prefix precedence in mapToolName
buildPeriodData and per-session output use raw totalOutputTokens without
adding reasoning tokens. buildJsonReport already handles this correctly
via billableOutputTokens(). This is a pre-existing gap that also affects
Claude — not introduced by the Hermes provider.
@iamtoruk
Copy link
Copy Markdown
Member

Thanks for contributing this. The provider structure is solid and test coverage is good. Found a few things that need fixing before we can merge:

Must fix

1. Cost fallback bug (hermes.ts:619)

const actualCost = row.actual_cost_usd ?? row.estimated_cost_usd ?? 0

?? does not trigger for 0, only for null/undefined. So when actual_cost_usd = 0 (explicit zero, not null) and estimated_cost_usd = 0.50, the chain returns 0, skips the estimate entirely, and falls through to calculatedCost. Need explicit null checks:

const costUSD =
  (row.actual_cost_usd ?? 0) > 0 ? row.actual_cost_usd!
  : (row.estimated_cost_usd ?? 0) > 0 ? row.estimated_cost_usd!
  : calculatedCost

2. inferProject matches all message roles (hermes.ts:480)

The cwdPattern regex runs against every message including assistant responses. An assistant quoting "Current working directory: /tmp/something" in its output would set the wrong project path. Filter to role === 'user' only (or role === 'system').

3. CACHE_VERSION bump is unnecessary (session-cache.ts)

Bumping from 3 to 4 forces a full cache rebuild for every user on upgrade (all providers, not just hermes). The cache schema did not change. The PROVIDER_PARSE_VERSIONS entry you already added for hermes is the right mechanism here and is sufficient on its own. Please revert CACHE_VERSION back to 3.

Should fix

4. Discovery query has no LIMIT (hermes.ts:506)

The SELECT ... FROM sessions WHERE usage > 0 has no bound. A user with a large Hermes database would load all rows into memory. Add a LIMIT 10000 or similar cap.

5. sanitizeProject strips only one leading separator (hermes.ts:320)

trimmed.replace(/^[/\\]/, '')

Missing the + quantifier. A path like //network/share becomes -network-share. Should be /^[/\\]+/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support for Hermes-agent CLI

2 participants