Skip to main content
Open source · MIT

mekik

The realtime serving layer for ilmek graphs. Turn a running graph into a live conversation — streaming generative UI, tool traces, and durable human-in-the-loop over one wire protocol.

import { graph, channel, START, END } from "@ilmek/core";
import { mekik } from "@mekik/core";
import { serveWs } from "@mekik/ws";

const g = graph("refund")
.channel("input", channel.lastWrite<string>(""))
.channel("reply", channel.lastWrite<string>(""))
.node("gate", async (s, ctx) => {
mekik.ui(ctx, "order-card", { id: s.input }); // stream GenUI
const ok = await mekik.approve<{ approved: boolean }>( // pause for a human
ctx,
{ title: `Refund ${s.input}?` },
{ ui: { component: "approval-form", props: { orderId: s.input } } },
);
return { reply: ok.approved ? "refunded" : "cancelled" };
})
.edge(START, "gate").edge("gate", END)
.compile();

const app = mekik({ graph: g, reply: (s) => s.reply as string });
serveWs(app, { port: 8800, path: "/ws" });

What mekik gives your graph

Everything below comes from @mekik/core + @mekik/ws (or Mekik.Core + Mekik.AspNetCore). Your graph stays pure ilmek.

🧵

One graph run = one turn

Point mekik at a compiled ilmek graph. Each user message drives one run; text, generative UI, tool traces and pauses stream back over one socket. The graph never learns it is being served.

⏸️

Durable human-in-the-loop

A node calls mekik.approve and suspends. The pause lives in ilmek's checkpoint — it survives a restart — and resumes exactly where it stopped, answered by a thread-scoped interrupt id.

🎯

Exactly-once side effects

mekik.tool journals each side effect through ctx.step. A resume re-runs the node from the top, but the tool it already ran is memoized — a refund never charges twice.

🪄

Generative UI streaming

Emit ui / text / event chunks with mekik.ui and mekik.text. They travel as genui frames carrying the same AIChunk shape chativa already renders inline.

🔁

Watermark resume

Persistent frames carry a per-conversation seq. Reconnect with your watermark and the server replays exactly what you missed — multi-tab and multi-device out of the box.

⚖️

Two languages, one wire

TypeScript (reference) and .NET (port) speak byte-identical mekik/1, held to that promise by shared golden fixtures replayed through both mappers.