Monorch

The AI control plane for TypeScript backends.

Agents and graphs in the server you already have. One event bus. No framework.

@monorch/ai@0.2.0 · pnpm add @monorch/ai

How it sits in your backend

live path

Your server

Your HTTP · Fastify · Hono · Nest

route handlers call

@monorch/ai

agent · tool · graph · stream

state + validate in

Rust engine

schema · permissions · cursors

Models

OpenAI / LiteLLM

Events

AiEvent → SSE

Resume

checkpoint / HITL

Smoke path

What a library smoke looks like.

SSE from agent.stream, then interrupt, checkpoint, and resume. Same events you wire to OTel. Not a Studio.

Run the smoke

POST /support/stream

Library, not a framework

What actually ships.

Tool loops with permissions, graphs you can pause and restore, a shared event stream, and thin bridges for MCP and OpenTelemetry. Rust keeps the state honest.

agent.stream
Unified AiEvent bus for SSE and UIs
graph + interrupt
Human gates with thread checkpoints
mcpTools
Remote tools as local tool() defs
createOtelListener
Spans from the same events
handoffs
Route between named agents
memory store
BYO key/value and thread history

In your handlers

Drop in. Keep the server.

One package. Native runtime underneath. Prefer graph() for orchestration.

refund.ts
import { graph, memorySaver, inMemoryStore } from "@monorch/ai";

const memory = inMemoryStore();
const refund = graph("refund")
  .node("lookup", async ({ input }) => {
    await memory.put(["orders"], String(input.orderId), { ok: true });
    return { output: `order:${input.orderId}`, state: { orderId: input.orderId } };
  })
  .interrupt("approve", { prompt: "Approve refund?" })
  .node("pay", async ({ outputs }) => `refunded:${outputs.lookup}`)
  .compile({ checkpointer: memorySaver() });

let run = await refund.start({ orderId: "ord_9" }, { threadId: "t1" });
if (run.status === "waitingInterrupt") {
  run = await run.resume("approved");
}

Fit

Beside your stack, not on top of it.

HTTP

Your server keeps the request lifecycle — Fastify, Hono, Nest, or plain Node. Monorch runs inside handlers.

Models

OpenAI-compatible baseUrl. LiteLLM, OpenRouter, and local gateways work the same way.

Durability

Checkpoints for interrupts. BYO memory and checkpointer. Reach for Inngest or Temporal when process death is the constraint.

Straight answers

Drop into your handlers.

Start with Getting started, then pick a recipe — HTTP with Fastify is one option among several.