Concepts
Runtime architecture and contract boundaries
Core Runtime Model
The SDK is implemented as Redux Toolkit slices + thunks.
- State:
npc,directive,memory,cortex,bridge,ghost,soul - API transport:
sdkApiRTK Query endpoints - Protocol execution:
processNPCthunk
Body vs Mind Boundary
- SDK = execution layer (the body)
- API = decision layer (the mind)
The SDK does not synthesize directives, construct prompts, or perform final action validation independently.
Multi-Round Protocol (Implemented Sequence)
Primary path (current SDK runtime):
POST /npcs/{npcId}/processwith{ tape, lastResult }- local instruction execution (
IdentifyActor,QueryVector,ExecuteInference) - repeat
/processuntil finalize instruction - local state/memory application from finalize payload
Compatibility path (also supported by API):
POST /npcs/{npcId}/directive- local memory recall (if instructed)
POST /npcs/{npcId}/context- local completion (
ICortex.complete) POST /npcs/{npcId}/verdict- local state/memory application
Required Inputs for processNPC
apiUrltextcortex(local runtime cortex)npcIdor active NPC in state- persona (arg or active NPC persona)
If API instructions require memory operations, a memory engine must be provided.
Node vs Browser Runtimes
Both @forbocai/node and @forbocai/browser provide the same protocol contract — they differ only in how local side-effects are executed.
Node (@forbocai/node):
- Cortex:
node-llama-cpprunning GGUF models on CPU/GPU - Memory: LanceDB file-based vector DB (persists across process restarts)
- CLI:
npx forbocai <command>for terminal workflows
Browser (@forbocai/browser):
- Cortex: WebLLM running in a WebGPU-capable browser tab
- Memory: Orama in-memory vector search (ephemeral per session)
- No CLI
Both environments execute the same multi-round protocol against the same API. The SDK is the “body” — it runs inference and stores vectors locally regardless of platform.
