Rensei docs
Typescript

TypeScript SDK

@donmai/* TypeScript SDK packages.

The @donmai/* packages are open-source MIT software. The authoritative API reference, changelog, and guided tutorials live at donmai.dev/docs. This page orients you to the package surface and shows how each package connects to the Rensei platform.

The @donmai/* family is the TypeScript layer that powers Rensei's execution engine. You use it when you need to embed agent orchestration into your own Next.js or Node.js application, extend the platform with a custom sandbox provider, or build UI components that display live session data.


Package catalogue

All packages ship on npm under the @donmai scope and require Node.js ≥ 22.

@donmai/core

Agent orchestration primitives - orchestrator, providers, kits, crash recovery, governor, routing, merge-queue integration. The foundational runtime layer.

@donmai/server

Redis storage primitives for workers, sessions, inbox, quota, and file reservation. Used by the platform's Next.js API routes and any self-hosted server.

@donmai/dashboard

Premium React UI components for session monitoring - session list, activity stream, health indicators. Drop into any Next.js app to show live agent status.

@donmai/plugin-linear

Linear issue tracker integration. Status transitions, AgentSession lifecycle, rate-limit shim (TokenBucket + CircuitBreaker), and work routing.

@donmai/mcp-server

MCP server that exposes Donmai fleet capabilities to any MCP-aware client. Connects the daemon's tool surface to Claude, Cursor, and other hosts.

@donmai/cli

CLI tooling for local orchestration, remote worker management, and queue administration. Used when scripting is preferred over the binary.

@donmai/nextjs

Next.js API route handlers for self-hosted deployments - webhook processor, worker/session management routes, public stats, OAuth callback, and middleware factory. The recommended starting point when building your own Rensei-compatible Next.js backend.

@donmai/architectural-intelligence


Quick install

npm install @donmai/core @donmai/server
pnpm add @donmai/core @donmai/server
yarn add @donmai/core @donmai/server

All packages are ES module ("type": "module") and ship TypeScript declarations alongside their compiled output.


How packages relate to Rensei

Your Application / Next.js API Route

        ├─ @donmai/core        ← agent lifecycle, providers, kits, routing
        ├─ @donmai/server      ← Redis queues, session state, inbox
        ├─ @donmai/plugin-linear ← Linear issue tracker wiring

        └──► Rensei Platform API  (REST / worker protocol)

                    └──► af daemon (Go)  ←── @donmai/mcp-server

The Rensei platform itself is built on top of @donmai/core and @donmai/server. Your extensions share the same primitives.


Core package - top-level exports

@donmai/core re-exports all sub-namespaces from a single entry point:

import {
  // Agent orchestration
  Orchestrator,
  // Provider families (11+ sandbox providers)
  SandboxProvider,
  // Kits - portable toolchain bundles
  Kit,
  // Governor - capacity and scheduling
  Governor,
  // Routing - MAB/Thompson Sampling
  Router,
  // Observability
  ObservabilityEmitter,
  // Workflow engine types
  WorkflowDefinition,
  // Issue tracker adapters
  IssueTracker,
} from '@donmai/core'

For the complete type signatures and extension points, see donmai.dev/docs/packages/core.


Server package - Redis primitives

@donmai/server provides the storage layer that the platform's worker protocol runs on:

import { createSessionStore, createWorkerRegistry, createInboxQueue } from '@donmai/server'

const sessions = createSessionStore(redis)
const workers = createWorkerRegistry(redis)
const inbox = createInboxQueue(redis)

// Reserve files across concurrent sessions
await sessions.reserveFiles(sessionId, ['src/app/page.tsx'])

This package is the right dependency when you are running your own daemon-compatible server alongside the platform, or when writing integration tests that need a real Redis-backed session store.


Dashboard package - session UI

@donmai/dashboard ships pre-built React components for embedding agent session status into your application:

import { SessionList, SessionDetail, ActivityStream } from '@donmai/dashboard'
import '@donmai/dashboard/styles.css'

export default function AgentPage({ projectSlug }: { projectSlug: string }) {
  return (
    <SessionList
      projectSlug={projectSlug}
      apiBase="https://app.rensei.ai"
      token={process.env.RENSEI_API_KEY}
    />
  )
}

Components connect to the public sessions API and stream updates over SSE. No additional backend is required.


Linear plugin - rate-limit aware client

@donmai/plugin-linear wraps the Linear API with a battle-tested rate-limit shim:

import { createLinearClient, withRetry } from '@donmai/plugin-linear'

const linear = createLinearClient({
  apiKey: process.env.LINEAR_API_KEY,  // or use the platform proxy
})

// Built-in TokenBucket + CircuitBreaker - safe at high volume
const issue = await withRetry(() => linear.issue(issueId))

Platform agents authenticate through the Rensei proxy (rensei linear CLI) and must NOT set LINEAR_API_KEY directly. See agents use rensei proxy for details.


MCP server - tool surface for agent hosts

@donmai/mcp-server starts an MCP server that exposes your Donmai fleet to Claude Code, Cursor, and other MCP-capable hosts:

import { startMcpServer } from '@donmai/mcp-server'

await startMcpServer({
  fleetApiUrl: 'https://app.rensei.ai',
  apiKey: process.env.RENSEI_API_KEY,
  port: 3100,
})

The platform also exposes a built-in MCP endpoint at POST /api/mcp/[sessionId] (JSON-RPC 2.0). See MCP session tools for the tool schema.


Next.js package - self-hosted route handlers

@donmai/nextjs provides pre-built Next.js App Router route handlers for teams that run their own Donmai-compatible backend rather than using the Rensei hosted platform. It is the fastest path to a self-hosted setup:

// app/api/[[...donmai]]/route.ts
import { createAllRoutes, createDefaultLinearClientResolver } from '@donmai/nextjs'

const { GET, POST, DELETE } = createAllRoutes({
  // webhookSecret falls back to LINEAR_WEBHOOK_SECRET env var
  webhookSecret: process.env.LINEAR_WEBHOOK_SECRET,
  linearClient: createDefaultLinearClientResolver(),
  appUrl: process.env.NEXT_PUBLIC_APP_URL!,
})

export { GET, POST, DELETE }

createAllRoutes mounts all worker-protocol, session lifecycle, webhook ingest, public stats, and OAuth callback routes under a single catch-all segment. It uses the same contracts as the hosted platform, so the af daemon connects to it without configuration changes.

The package also exports a createAgentFactoryMiddleware factory for Next.js middleware (CORS, auth forwarding, session pinning) and createWebhookOrchestrator for integrating custom webhook processors alongside the built-in pipeline.

pnpm add @donmai/nextjs @donmai/core @donmai/server

Versioning

All @donmai/* packages are versioned together. The current stable release is v0.9.x. Breaking changes are rare; the packages follow semantic versioning.

Check donmai.dev/docs/changelog for the full release history and upgrade notes.


No dedicated "Rensei API client" today

There is no @rensei/sdk package yet - consumers call the Rensei REST API directly or use @donmai/* packages for the runtime layer. A typed API client generated from the platform's OpenAPI spec is on the roadmap (Phase 3 of the API reference plan).

For now, the simplest way to call the Rensei REST API programmatically is with Authorization: Bearer rsk_live_<token> on https://app.rensei.ai. See API keys and the API overview for auth details.

On this page