Integration Workflow
Source-accurate setup for protocol execution
1. Configure API Access
$ export FORBOCAI_API_URL=https://api.forboc.ai $ export FORBOCAI_API_KEY=fb_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2. Create Store and Runtime Components
1 import { 2 createSDKStore, 3 setNPCInfo, 4 processNPC, 5 listMemoryRemoteThunk, 6 validateBridgeThunk, 7 remoteExportSoulThunk 8 } from '@forbocai/core'; 9 import { createNodeCortex } from '@forbocai/node'; 10 11 const store = createSDKStore(); 12 13 store.dispatch(setNPCInfo({ 14 id: 'npc_guard_001', 15 persona: 'A strict city gate guard.', 16 initialState: { alertLevel: 0 } 17 })); 18 19 const cortex = createNodeCortex('smollm2-135m'); 20 await cortex.init();
3. Run Protocol Turn
1 const turn = await store.dispatch(processNPC({ 2 npcId: 'npc_guard_001', 3 text: 'I need entry to the city.', 4 context: { playerReputation: 12 }, 5 apiUrl: process.env.FORBOCAI_API_URL || 'https://api.forboc.ai', 6 apiKey: process.env.FORBOCAI_API_KEY, 7 cortex 8 })).unwrap(); 9 10 console.log(turn.dialogue); 11 console.log(turn.action);
4. Optional Remote Operations
1 // memory list 2 const memories = await store.dispatch(listMemoryRemoteThunk({ 3 npcId: 'npc_guard_001', 4 apiUrl: 'https://api.forboc.ai', 5 apiKey: process.env.FORBOCAI_API_KEY 6 })).unwrap(); 7 8 // bridge validate 9 const validation = await store.dispatch(validateBridgeThunk({ 10 action: { type: 'OPEN_GATE' }, 11 context: { npcState: { alertLevel: 0 } }, 12 apiUrl: 'https://api.forboc.ai', 13 apiKey: process.env.FORBOCAI_API_KEY 14 })).unwrap(); 15 16 // soul export 17 const soul = await store.dispatch(remoteExportSoulThunk({ 18 npcId: 'npc_guard_001', 19 apiUrl: 'https://api.forboc.ai', 20 apiKey: process.env.FORBOCAI_API_KEY 21 })).unwrap(); 22 23 console.log(memories.length, validation.valid, soul.txId);
5. CLI Workflow Alternative
$ npx forbocai config set apiUrl https://api.forboc.ai $ npx forbocai config set apiKey fb_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx $ $ npx 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>
