@onioneko/kiki-core
v0.1.3
Published
Middleware runner for LLM agents — compose, stacks, input queue, message state
Maintainers
Readme
@onioneko/kiki-core
Kiki · Middleware framework for LLM agents
Stateless middleware composition engine. Generic — knows nothing about LLMs, conversations, or agents.
npm install @onioneko/kiki-coreExports
compose(middlewares)— Turn an array of middleware into a single function. Onion (Koa-style) execution order.createStack()— Create a mutable middleware group. Children managed via.add()and.remove()splice into the chain transparently.Context— Open map ([key: string]: unknown). Middleware ecosystems define their own conventions.Middleware—(ctx: Context, next: () => Promise<void>) => Promise<void>
Usage
import { compose, createStack } from "@onioneko/kiki-core";
const stack = createStack();
stack.add(async (ctx, next) => {
ctx.before = true;
await next();
ctx.after = true;
});
const chain = compose([
async (ctx, next) => { await next(); },
stack.middleware,
]);
const ctx = {};
await chain(ctx);Design
- ~80 lines, zero runtime dependencies
- Context is an open map — no opinions
- Middleware mutates shared context, no return values
- Stacks are transparent slots — children compose as onion within the chain
