Memory (RAG)

Remote memory operations and protocol-driven local memory requirements

View as Markdown

Memory behavior in sdk@0.6.3 is driven by protocol instructions and remote memory endpoints.

Protocol Semantics

During processNPC:

  • API can request recall via memoryRecall
  • API can request storage via memoryStore
  • If either is requested and no memory engine is configured, processNPC fails fast

Remote Memory Thunks

1import {
2 createSDKStore,
3 listMemoryRemoteThunk,
4 recallMemoryRemoteThunk,
5 storeMemoryRemoteThunk,
6 clearMemoryRemoteThunk
7} from '@forbocai/core';
8
9const store = createSDKStore();
10const apiUrl = 'https://api.forboc.ai';
11const apiKey = process.env.FORBOCAI_API_KEY;
12
13const listed = await store.dispatch(listMemoryRemoteThunk({
14 npcId: 'npc_1',
15 apiUrl,
16 apiKey
17})).unwrap();
18
19const recalled = await store.dispatch(recallMemoryRemoteThunk({
20 npcId: 'npc_1',
21 query: 'merchant key',
22 apiUrl,
23 apiKey
24})).unwrap();
25
26await store.dispatch(storeMemoryRemoteThunk({
27 npcId: 'npc_1',
28 observation: 'Player bought the old key',
29 importance: 0.9,
30 apiUrl,
31 apiKey
32})).unwrap();
33
34await store.dispatch(clearMemoryRemoteThunk({
35 npcId: 'npc_1',
36 apiUrl,
37 apiKey
38})).unwrap();

CLI

$npx forbocai memory list <npcId>
$npx forbocai memory recall <npcId> <query>
$npx forbocai memory store <npcId> <text>
$npx forbocai memory clear <npcId>
$npx forbocai memory export <npcId>