codeburn icon indicating copy to clipboard operation
codeburn copied to clipboard

Add Hermes Agent CLI provider

Open ozymandiashh opened this issue 6 months ago • 1 comments

Summary

Closes #368 by adding Hermes-agent CLI support through Hermes' current SQLite state store at ~/.hermes/state.db.

Context

Hermes-agent now persists session metadata, messages, tool calls, token usage, and cost fields in state.db. CodeBurn did not have a Hermes provider, so --provider hermes could not discover or report those CLI sessions.

What changed

  • Add a lazy-loaded hermes provider backed by shared SQLite helpers.
  • Discover Hermes root sessions from ~/.hermes/state.db, with HERMES_HOME override support.
  • Parse root and child session trees, including cycle-safe recursive traversal.
  • Decode user/assistant messages, structured \0json: content, assistant tool_calls, fallback role = 'tool' rows, Bash commands, web searches, and MCP tool names.
  • Preserve Hermes stored estimated/actual costs in cache while keeping locally calculated costs recomputable when pricing changes.
  • Add Hermes to provider discovery, keyword metadata, and session-cache environment fingerprinting.

Validation

I created a realistic Hermes state.db fixture with one CLI session:

session: manual-root
source: cli
model: anthropic/claude-sonnet-4.6
input_tokens: 1200
output_tokens: 340
cache_read_tokens: 90
cache_write_tokens: 40
actual_cost_usd: 0.031
tool_calls: terminal(command: npm test ...), write_file(path: src/providers/hermes.ts)

Running CodeBurn against that fixture with --provider hermes produced the expected model, tokens, cost, tools, and shell command:

calls: 1
cost: 0.031
tokens: input 1200, output 340, cacheRead 90, cacheWrite 40
model: Sonnet 4.6
tools: Bash 1, Write 1
shellCommands: npm 1

The same path is covered by tests/cli-hermes-provider.test.ts, which builds a temporary ~/.hermes/state.db and runs the real CLI with --provider hermes.

Additional checks:

  • npm test -- --run tests/providers/hermes.test.ts tests/cli-hermes-provider.test.ts tests/provider-registry.test.ts - 25 tests passed
  • npm test -- --run - 67 files / 909 tests passed
  • npm run build
  • git diff --check

Notes

  • Older closed Hermes PRs (#46 and #200) targeted stale or incomplete storage assumptions; this implementation is based on the current Hermes state.db schema.
  • Recursive session traversal is bounded/cycle-safe for malformed parent links.
  • Assistant tool_calls and following role = 'tool' result rows are not double-counted.

ozymandiashh avatar May 21 '26 09:05 ozymandiashh

Thanks for adding Hermes Agent support. Heads up that there are three open PRs for the same provider (#442, #386, #370). After reviewing all three, #442 is the one being moved forward as the base, mainly because it is the leanest and follows the existing provider conventions most closely (HERMES_HOME override, read-only parameterized sqlite, the cursor-style path encoding). That is not a knock on this PR, just avoiding two Hermes providers landing.

We will consolidate on #442 (it has review feedback to address first). I will close this one to avoid duplication, but please do weigh in on #442 if there is anything from your implementation worth folding in. Appreciate the work.

iamtoruk avatar Jun 06 '26 21:06 iamtoruk

Closing in favor of #442, which you picked as the base for Hermes support. Thanks!

ozymandiashh avatar Jun 21 '26 13:06 ozymandiashh