Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
import type { Recipe } from '../types.ts';
/**
* Claude via the local `claude` CLI binary, using its built-in OAuth session
* (Claude Code / Claude Max subscription). No ANTHROPIC_API_KEY needed — the
* CLI manages its own auth state and the gateway dispatches via subprocess.
*
* Solves the #334 case where Max subscribers want Minions subagent dispatch
* to run against their existing subscription instead of paying per-token API
* charges. The recipe sits alongside the existing `anthropic` recipe so users
* pick per call: `anthropic:claude-sonnet-4-6` (API key + per-token billing)
* vs `claude-cli:claude-sonnet-4-6` (OAuth subscription, no API key).
*
* Chat + expansion; no embedding. Claude has no first-party embedding model;
* users wanting an Anthropic chat path with embeddings still combine this with
* openai/google/voyage for embedding the way the existing `anthropic` recipe
* documents.
*
* Auth: `auth_env.required: []` because the CLI handles auth itself. The
* `claude` binary on PATH (or `GBRAIN_CLAUDE_CLI_BIN`) IS the auth surface;
* there is nothing for the gateway to forward.
*
* Setup expectation: `claude` CLI installed and logged in (Claude Code
* onboarding does this), or `GBRAIN_CLAUDE_CLI_BIN` pointing at the binary.
*/
export const claudeCli: Recipe = {
id: 'claude-cli',
name: 'Claude (via CLI)',
tier: 'native',
implementation: 'claude-cli',
// Calls bill against the operator's Claude subscription, not per token, so
// `pricing.overrides` accepts a `claude-cli:*` provider wildcard (e.g. $0).
// Without one, claude-cli models price at Anthropic's API list rate.
billing: 'subscription',
// The CLI owns auth; no env vars are required from the gateway side.
auth_env: {
required: [],
},
touchpoints: {
// No embedding touchpoint — Claude has no first-party embedding model.
//
// `expansion` IS declared (it was not, pre-fix). Without it,
// `isAvailable('expansion')` in gateway.ts returns false for every
// claude-cli model, so `expandQuery()` in src/core/search/expansion.ts
// returns [query] before any model call — query expansion silently
// disappears with no error and no log line, and `gbrain models doctor`
// still reports the touchpoint green because its probe calls `chat()`
// with an explicit `model:` override and never consults the recipe.
// A brain whose tier.utility points at claude-cli therefore lost the
// multi-query recall arm that `query` exists to provide.
//
// instantiateExpansion() in gateway.ts already had a `case 'claude-cli'`
// waiting for this declaration; it returns the same
// ClaudeCliLanguageModel that chat uses.
expansion: {
// Cheap model first: `providers explain` / init auto-pick advertise
// models[0] for this touchpoint (same convention as the openai recipe).
models: [
'claude-haiku-5-5',
'claude-haiku-4-5-20251001',
'claude-fable-5',
'claude-fable-5-1',
'claude-opus-5-5',
'claude-opus-5',
'claude-opus-4-8',
'claude-opus-4-7',
'claude-sonnet-5-5',
'claude-sonnet-5',
'claude-sonnet-4-6',
],
// Nominal — the subscription bears the actual bill. Mirrors the chat
// touchpoint's rationale below.
cost_per_1m_tokens_usd: 3.0,
price_last_verified: '2026-06-17',
// Same subprocess cold start as chat: `claude -p` routinely takes 5-6s
// before emitting a token. The probe's flat 5000ms default would
// false-fail on every run.
default_timeout_ms: 30_000,
},
chat: {
models: [
'claude-fable-5',
'claude-fable-5-1',
'claude-opus-5-5',
'claude-opus-5',
'claude-opus-4-8',
'claude-opus-4-7',
'claude-sonnet-5-5',
'claude-sonnet-5',
'claude-sonnet-4-6',
'claude-haiku-5-5',
'claude-haiku-4-5-20251001',
],
supports_tools: true,
supports_subagent_loop: true,
// The CLI caches prompt prefixes automatically — including the
// `--print` runs this provider dispatches, which Claude Code puts in
// its "main conversation" TTL bucket (one hour on a Claude
// subscription, five minutes on an API key).
// https://code.claude.com/docs/en/prompt-caching
//
// This field asks "does the provider cache at all" — see the contract
// on ProviderCapabilities.supportsPromptCaching in ../capabilities.ts,
// which is explicit that it is NOT "does it honor our markers", and
// that the degraded:no_caching advice "is wrong for a provider that
// caches without being asked". It was exactly that advice this recipe
// used to trigger. Declaring `false` because the gateway cannot drive
// the cache answered the other question.
supports_prompt_cache: true,
max_context_tokens: 200000,
// Cost figures match the underlying Claude API tier, but the actual
// bill is borne by the subscription. We report them for the budget
// ledger's per-call accounting; operators on flat-rate subscriptions
// can treat the numbers as nominal.
cost_per_1m_input_usd: 3.0,
cost_per_1m_output_usd: 15.0,
price_last_verified: '2026-06-17',
// The gateway dispatches via a `claude -p (print mode)` subprocess (CLI cold
// start + user-level CLAUDE.md load), which routinely takes 5-6s even
// when the CLI and subscription are perfectly healthy. `gbrain models
// doctor`'s chat probe used to hardcode a flat 5000ms abort, so this
// recipe always false-failed the doctor check ('unknown — claude-cli
// adapter aborted') despite `chat()` succeeding fine at normal call
// sites. 30s gives the subprocess room to start without masking a truly
// dead/unauthenticated CLI for anywhere near that long.
default_timeout_ms: 30_000,
},
},
// Friendly aliases mirror the `anthropic` recipe so config strings stay
// portable: switching `anthropic:claude-sonnet-4-6` to `claude-cli:claude-sonnet-4-6`
// is a one-token edit. Reverse aliases rewrite legacy IDs back to canonical.
aliases: {
'claude-haiku-4-5': 'claude-haiku-4-5-20251001',
'claude-sonnet-4-6-20250929': 'claude-sonnet-4-6',
'sonnet': 'claude-sonnet-4-6',
'haiku': 'claude-haiku-4-5-20251001',
'opus': 'claude-opus-4-7',
},
setup_hint:
'Install Claude Code (`claude` CLI) and run `claude` once to log in. ' +
'Set GBRAIN_CLAUDE_CLI_BIN if the binary is not on PATH.',
};