This page is the type-level reference for the two main extension points in the SDK: theDocumentation Index
Fetch the complete documentation index at: https://docs.waniwani.ai/llms.txt
Use this file to discover all available pages before exploring further.
KvStore interface (any flow uses it) and the waniwani() client (used by Platform features).
KvStore interface
Built-in implementations
MemoryKvStorefrom@waniwani/sdk/mcp. An in-memoryMap. Resets on process restart.WaniwaniKvStorefrom@waniwani/sdk/mcp. Persists againstapp.waniwani.ai. Selected automatically whenWANIWANI_API_KEYis set and no explicitstoreis passed.
What gets stored
Each session maps to one key. The engine stores:- The current node (or
ENDwhen complete) - The merged state object so far
- A pending widget reference, if the current node is a
showWidgetstep
_meta.waniwani/sessionId or Mcp-Session-Id), so isolating sessions is automatic. Values are JSON-serializable plain objects.
waniwani() client
WANIWANI_API_KEY from the environment and targets https://app.waniwani.ai.
Your MCP environment API key. Defaults to
process.env.WANIWANI_API_KEY. If both are missing, track() / flush() / shutdown() throw at runtime.Base URL of the WaniWani API. Override for self-hosted deployments or staging backends.
Fine-tune the event tracking transport.
Graceful shutdown
In Node environments, the SDK attaches handlers forbeforeExit, SIGINT, and SIGTERM that flush buffered events automatically. For serverless, edge runtimes, tests, or short-lived scripts, call shutdown() explicitly: