@lore-context/sdk-middleware
v0.1.0
Published
SDK middleware for Lore Context — auto-inject memory pre-LLM-call and auto-retain post-LLM-call across OpenAI/Anthropic/OpenRouter SDKs.
Maintainers
Readme
@lore-context/sdk-middleware
SDK middleware for Lore Context — wraps OpenAI / Anthropic / OpenRouter SDK clients to auto-inject memory pre-LLM-call and auto-retain post-LLM-call without requiring the AI to call an MCP tool.
Install
pnpm add @lore-context/sdk-middleware @lore-context/sdk openaiQuick start
import OpenAI from "openai";
import { LoreContextApiClient } from "@lore-context/sdk";
import { withMemoryHooks } from "@lore-context/sdk-middleware";
const lore = new LoreContextApiClient({ token: process.env.LORE_API_KEY! });
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const client = withMemoryHooks(openai, lore, { mode: "hybrid" });
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "What was that Postgres dump command?" }],
});Modes
| Mode | inject | retain | tools exposed |
|---|---|---|---|
| hybrid (default) | ✅ | ✅ | ✅ |
| context | ✅ | ✅ | ❌ |
| tools | ❌ | ❌ | ✅ |
See docs/sdk/middleware-modes.md in the lore-cloud repo for full mode semantics.
License
MIT — see LICENSE.
