niadraProcessor() is an input and output processor for the Mastra agent: it rewrites the prompt of each model call without touching the message list and records the final answer. niadraTools(session) returns the history kit as Mastra tools. TypeScript only.
Install
@niadra/sdk 0.3.0, ready on main and on npm when it is published; until then the npm package is 0.1.1.
The five primitives
The session comes from the request context (
requestContext.set("niadra", convo)), or is fixed when the processor is built for one conversation.
Minimal example
examples/mastra.ts.
Agent memory
niadraProcessor({ agentMemory: true }) puts the agent’s own notes before the customer’s context, and niadraTools(convo, { agentMemory: { write: true } }) adds the two tools. See Agent memory.
Limits
- Mastra’s
Memory(threads, working memory) stays Mastra’s; Niadra is the customer’s memory shared with the company’s other agents. - Nothing here fails the call: without a pack, the prompt goes as Mastra built it.
- Tested against
@mastra/core1.71 with a fake model and Niadra on the emulator.
Next steps
Vercel AI SDK
the middleware for
wrapLanguageModel.TypeScript SDK
the conversation, the
suffix and markInjected().
