***

title: Unreal Engine SDK
subtitle: Store/thunk runtime for Unreal Engine 5.7
slug: ue/welcome
----------------

The current Unreal Engine plugin mirrors `@forbocai/core` and `@forbocai/node`: a shared store, slice state, selectors, and thunks. The public runtime is centered on `FSDKState`, `createSDKStore()`, `SDKOps`, and `rtk::*Thunk` APIs.

<Note>
  This page reflects the current `sdk-ue-5.7.3` source. It does not describe the older factory-style integration examples that still exist in parts of the historical demo project.
</Note>

## What Ships

* `RuntimeStore.h`: `FSDKState`, `createSDKStore()`, `ConfigureSDKStore()`
* `NPC/NPCSlice.h`: NPC entity state, selectors, history, block state
* `Protocol/ProtocolThunks.h`: `rtk::processNPC(...)` multi-turn protocol execution
* `Memory/MemoryThunks.h`: remote memory and local node-backed memory
* `Cortex/CortexThunks.h`: local llama.cpp and remote cortex helpers
* `Bridge/BridgeThunks.h`: validation, presets, and rulesets
* `Soul/SoulThunks.h`: local export, remote export/import, list, verify
* `Ghost/GhostThunks.h`: Ghost session start/status/results/history
* `CLI/CliOperations.h`: synchronous `SDKOps::*` wrappers over the same thunks
* `RuntimeBlueprintLibrary.h`: Blueprint-callable wrappers for a smaller subset

## Canonical Runtime Pattern

Use `createSDKStore()` when you want your own store instance in C++. The synchronous `SDKOps` helpers are thin adapters over store dispatch and match the CLI/test workflow in the plugin.

```cpp
#include "RuntimeStore.h"
#include "RuntimeConfig.h"
#include "CLI/CliOperations.h"

auto Store = createSDKStore();
SDKConfig::SetApiConfig(TEXT("https://api.forboc.ai"), ApiKey);

FNPCInternalState Npc = SDKOps::CreateNpc(
    Store,
    TEXT("A cautious merchant who protects rare inventory."));

SDKOps::InitNodeMemory(Store, TEXT("/tmp/merchant.db"));
SDKOps::InitCortex(Store, TEXT("smollm2-135m"));

FAgentResponse Response =
    SDKOps::ProcessNpc(Store, Npc.Id, TEXT("Do you sell keys?"));

UE_LOG(LogTemp, Display, TEXT("%s"), *Response.Dialogue);
```

## Important Protocol Behavior

* `SDKOps::ProcessNpc(...)` and `rtk::processNPC(...)` run the API-directed multi-turn protocol, not a single completion call.
* `rtk::LocalProtocolRuntime()` is the default runtime used by the synchronous helpers.
* If the API asks for memory recall/store and local memory is not initialized, processing fails fast.
* If the API asks for inference and local cortex is not initialized, processing fails fast.
* A successful finalize step updates NPC state, last action, history, and any returned memory instructions.

## Access Layers

### Direct store/thunks

Best when you want parity with `packages/core` and `packages/node`.

```cpp
#include "RuntimeStore.h"
#include "NPC/NPCSlice.h"
#include "Memory/MemoryThunks.h"
#include "Cortex/CortexThunks.h"
#include "Protocol/ProtocolThunks.h"
```

### `SDKOps`

Best for commandlets, tests, and synchronous tooling.

```cpp
#include "CLI/CliOperations.h"
```

### Blueprints

Best for simple wrapper calls such as `CreateNpc`, `ProcessNpc`, `ExportSoul`, and config access.

```cpp
#include "RuntimeBlueprintLibrary.h"
```

## Next Pages

<CardGroup cols={2}>
  <Card title="Installation" icon="duotone plug" href="/ue/installation">
    Install the plugin, wire module dependencies, and configure runtime settings.
  </Card>

  <Card title="Architecture" icon="duotone diagram-project" href="/ue/architecture">
    See how `FSDKState`, slices, middleware, and thunks fit together.
  </Card>

  <Card title="NPC" icon="duotone user-robot" href="/ue/npc">
    Register NPCs, inspect selectors, and run the protocol loop.
  </Card>

  <Card title="Memory" icon="duotone brain" href="/ue/memory">
    Work with remote NPC memory and local node-backed recall.
  </Card>

  <Card title="Bridge" icon="duotone shield-check" href="/ue/bridge">
    Validate actions, load presets, and manage rulesets.
  </Card>

  <Card title="Soul" icon="duotone ghost" href="/ue/soul">
    Export, import, list, and verify portable Souls.
  </Card>
</CardGroup>
