> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.forboc.ai/api-reference/endpoints/forboc-ai-sdk-api/np-cs/process-npc-step/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.forboc.ai/_mcp/server. # Atomic protocol step POST https://api.forboc.ai/npcs/{npcId}/process Content-Type: application/json SDK sends the full accumulated tape and the result of the previous atomic side-effect. API returns the next atomic instruction and the updated tape. Reference: https://docs.forboc.ai/api-reference/endpoints/forboc-ai-sdk-api/np-cs/process-npc-step ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Servers - `https://api.forboc.ai` (ForbocAI API Production, default) - `http://localhost:8080` (Local Development) ## Request ### Path parameters - `npcId` (string, required) ### Body (application/json) This endpoint expects a NPCProcessRequest. - `tape` (NPCProcessTape, required) - `lastResult` (map from string to any, optional, nullable) ## Response ### 200 Next atomic instruction with updated tape - `instruction` (NPCInstruction, required) - `tape` (NPCProcessTape, required) ## Types ### NPCProcessTape - `observation` (string, required) - `npcState` (map from string to any, required) - `memories` (list of RecalledMemory, required) - `context` (map from string to any, optional) - `persona` (string, optional, nullable) - `actor` (NPC, optional, nullable) - `prompt` (string, optional, nullable) - `constraints` (PromptConstraints, optional, nullable) - `generatedOutput` (string, optional, nullable) - `rulesetId` (string, optional, nullable) - `vectorQueried` (boolean, optional, nullable) ### NPCInstruction ### RecalledMemory - `text` (string, optional) - `type` (enum, optional) - Allowed values: `observation`, `experience`, `knowledge`, `emotion` - `importance` (double, optional) - `similarity` (double, optional, nullable) ### NPC - `npcId` (string, optional) - `persona` (string, optional) - `data` (map from string to any, optional) ### PromptConstraints - `maxTokens` (integer, optional, nullable) - `temperature` (double, optional, nullable) - `stop` (list of string, optional, nullable) ### IdentifyActorInstruction - `type` (enum, optional) - Allowed values: `IdentifyActor` ### QueryVectorInstruction - `type` (enum, required) - Allowed values: `QueryVector` - `query` (string, required) - `limit` (integer, required) - `threshold` (double, required) ### ExecuteInferenceInstruction - `type` (enum, required) - Allowed values: `ExecuteInference` - `prompt` (string, required) - `constraints` (PromptConstraints, required) ### FinalizeInstruction - `type` (enum, required) - Allowed values: `Finalize` - `valid` (boolean, required) - `memoryStore` (list of MemoryStoreInstruction, required) - `stateTransform` (map from string to any, required) - `dialogue` (string, required) - `signature` (string, optional, nullable) - `action` (GenericAction, optional, nullable) ### MemoryStoreInstruction - `text` (string, optional) - `type` (enum, optional) - Allowed values: `observation`, `experience`, `knowledge`, `emotion` - `importance` (double, optional) ### GenericAction - `type` (string, optional) - `reason` (string, optional, nullable) - `target` (string, optional, nullable) ## Examples **Request** ```json { "tape": { "observation": "The NPC notices a suspicious figure lurking near the marketplace.", "npcState": {}, "memories": [ {} ] } } ``` **Response** ```json { "instruction": { "type": "IdentifyActor" }, "tape": { "observation": "The NPC notices a suspicious figure lurking near the marketplace.", "npcState": {}, "memories": [ { "text": "Saw a hooded stranger near the market yesterday evening.", "type": "observation", "importance": 0.85, "similarity": 0.92 } ], "context": {}, "persona": "A cautious and vigilant town guard.", "actor": { "npcId": "npc-12345", "persona": "Town Guard", "data": {} }, "prompt": "Identify the suspicious figure based on recent observations and memories.", "constraints": { "maxTokens": 150, "temperature": 0.7, "stop": [ "\n" ] }, "generatedOutput": "The suspicious figure appears to be a known thief recently reported in the area.", "rulesetId": "guard-protocol-v2", "vectorQueried": true } } ``` **SDK Code** ```python import requests url = "https://api.forboc.ai/npcs/npcId/process" payload = { "tape": { "observation": "The NPC notices a suspicious figure lurking near the marketplace.", "npcState": {}, "memories": [{}] } } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.forboc.ai/npcs/npcId/process'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"tape":{"observation":"The NPC notices a suspicious figure lurking near the marketplace.","npcState":{},"memories":[{}]}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.forboc.ai/npcs/npcId/process" payload := strings.NewReader("{\n \"tape\": {\n \"observation\": \"The NPC notices a suspicious figure lurking near the marketplace.\",\n \"npcState\": {},\n \"memories\": [\n {}\n ]\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.forboc.ai/npcs/npcId/process") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"tape\": {\n \"observation\": \"The NPC notices a suspicious figure lurking near the marketplace.\",\n \"npcState\": {},\n \"memories\": [\n {}\n ]\n }\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.forboc.ai/npcs/npcId/process") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"tape\": {\n \"observation\": \"The NPC notices a suspicious figure lurking near the marketplace.\",\n \"npcState\": {},\n \"memories\": [\n {}\n ]\n }\n}") .asString(); ``` ```php request('POST', 'https://api.forboc.ai/npcs/npcId/process', [ 'body' => '{ "tape": { "observation": "The NPC notices a suspicious figure lurking near the marketplace.", "npcState": {}, "memories": [ {} ] } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.forboc.ai/npcs/npcId/process"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"tape\": {\n \"observation\": \"The NPC notices a suspicious figure lurking near the marketplace.\",\n \"npcState\": {},\n \"memories\": [\n {}\n ]\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["tape": [ "observation": "The NPC notices a suspicious figure lurking near the marketplace.", "npcState": [], "memories": [[]] ]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.forboc.ai/npcs/npcId/process")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```