@kybernesis/brain-llm-claude
v0.17.0
Published
Claude subprocess LLM provider for brain-core
Readme
@kybernesis/brain-llm-claude
The default LLMProvider for Cortex — runs Claude through the local
claude CLI as a subprocess. It powers the
kernel's reasoning features: relationship and fact extraction, contradiction detection, user
profiles, and sleep-cycle reasoning.
Used with @kybernesis/brain-core. It satisfies the LLMProvider
interface; you inject it, the kernel calls callClaude / callClaudeJSON through it.
Install
pnpm add @kybernesis/brain-llm-claude @kybernesis/brain-coreRequires the claude CLI on PATH (authenticated). The kernel works without an LLM seam —
the reasoning features simply skip — so this provider is optional.
Usage
import { createSubprocessProvider, isClaudeAvailable } from '@kybernesis/brain-llm-claude';
import { setLLMProvider } from '@kybernesis/brain-core';
if (await isClaudeAvailable()) {
setLLMProvider(createSubprocessProvider());
}
// brain-core's LLM-backed steps now run; without it they no-op.Behaviour
- Shells out to
claude --printper call; resolves the model fromCLAUDE_MODEL_ALIASESin@kybernesis/brain-contracts. - Never throws into the kernel — spawn errors, non-zero exits, empty output, and timeouts
all resolve to
null(the kernel treats anullLLM result as "skip"). Surface failures via theonErrorhook (reason: 'spawn' | 'exit' | 'empty' | 'timeout'). timeoutMs(default60_000) sendsSIGTERMto a hung process so a stuckclaudecan't wedge a sleep cycle.
setLLMProvider(createSubprocessProvider({
timeoutMs: 30_000,
onError: (reason, detail) => log.warn(`claude ${reason}`, detail),
}));Notes
- ESM-only, TypeScript strict.
maxTokensis not supported by the CLI surface and is documented as a no-op.- Part of Cortex —
@kybernesis/brain-*.
