TypeScript-first SDK for building production-grade AI agents. Tools, memory, guardrails, handoffs, and tracing — composable by design.
Most AI SDKs give you too much magic or too little control. MITM sits in the middle — every part is a plain interface you can swap, extend, or ignore.
Define typed tools with JSON input schemas. Automatic validation, retries, and per-tool timeouts built in.
Multi-turn conversations with pluggable adapters. In-memory, file-based, or any database with a 3-method interface.
Input, output, and tool-level guardrails. Block, modify, or pass through at every layer. Safe by default.
Delegate tasks between specialized agents. Context is preserved. Loop detection is automatic.
Full run traces: step timing, token usage, tool calls, handoffs, errors. One call to get everything.
OpenAI built in. Swap to any LLM with a 2-method interface. Works with OpenRouter, Groq, Gemini, local models.
Install the package, set an API key, define your tools, and build your agent. The SDK handles the loop, tool dispatch, error recovery, and tracing.
import { Agent, OpenAIProvider } from "mitm-ai";
const agent = Agent.builder()
.setName("myAgent")
.setProvider(new OpenAIProvider())
.setInstructions("You are helpful.")
.tool(myTool)
.setMemory(new FileAdapter(), "user-1")
.addInputGuardrail(safetyCheck)
.setTimeout(30_000)
.build();
agent.on("step", (e) =>
console.log(e.step, e.content)
);
const result = await agent.run("Build hello.py");
const trace = agent.getLastTrace();
MIT licensed. Read the source, contribute, or fork it.