1. Configure API Access
export FORBOCAI_API_URL=https://api.forboc.aiexport FORBOCAI_API_KEY=fb_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2. Create Store and Runtime Components
import {createSDKStore,setNPCInfo,processNPC,listMemoryRemoteThunk,validateBridgeThunk,remoteExportSoulThunk} from '@forbocai/core';import { createNodeCortex } from '@forbocai/node';const store = createSDKStore();store.dispatch(setNPCInfo({id: 'npc_guard_001',persona: 'A strict city gate guard.',initialState: { alertLevel: 0 }}));const cortex = createNodeCortex('smollm2-135m');await cortex.init();
3. Run Protocol Turn
const turn = await store.dispatch(processNPC({npcId: 'npc_guard_001',text: 'I need entry to the city.',context: { playerReputation: 12 },apiUrl: process.env.FORBOCAI_API_URL || 'https://api.forboc.ai',apiKey: process.env.FORBOCAI_API_KEY,cortex})).unwrap();console.log(turn.dialogue);console.log(turn.action);
4. Optional Remote Operations
// memory listconst memories = await store.dispatch(listMemoryRemoteThunk({npcId: 'npc_guard_001',apiUrl: 'https://api.forboc.ai',apiKey: process.env.FORBOCAI_API_KEY})).unwrap();// bridge validateconst validation = await store.dispatch(validateBridgeThunk({action: { type: 'OPEN_GATE' },context: { npcState: { alertLevel: 0 } },apiUrl: 'https://api.forboc.ai',apiKey: process.env.FORBOCAI_API_KEY})).unwrap();// soul exportconst soul = await store.dispatch(remoteExportSoulThunk({npcId: 'npc_guard_001',apiUrl: 'https://api.forboc.ai',apiKey: process.env.FORBOCAI_API_KEY})).unwrap();console.log(memories.length, validation.valid, soul.txId);
5. CLI Workflow Alternative
npx forbocai config set apiUrl https://api.forboc.ainpx forbocai config set apiKey fb_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxnpx forbocai npc create "A strict city guard"npx forbocai npc process <npcId> "I need entry to the city"npx forbocai memory list <npcId>npx forbocai soul export <npcId>
