TypeScript-first AI agent SDK. Tools, memory, guardrails, handoffs, and tracing built in.
Typed input schemas, validation before execution, per-tool retries and timeouts. Errors feed back to the model.
guide/toolsIn-memory or file-based sessions out of the box. Implement IMemoryAdapter to connect any database.
guide/memoryInput, output, and tool-level safety checks. Block, modify, or pass through at every layer.
guide/guardrailsDelegate tasks between specialized agents. Context transfers cleanly. Loop detection is automatic.
guide/handoffsFull run traces with step timing, token usage, tool calls, handoffs, and errors. One method after run().
guide/tracingOpenAI built in. Swap to Gemini, Claude, or Groq by implementing a 2-method interface.
guide/providersInstall, set a key, define tools, build the agent. The loop, dispatch, and tracing are handled.
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));
const result = await agent.run("Build hello.py");
const trace = agent.getLastTrace();
// trace.durationMs trace.tokenUsage
Read the source, contribute, or ship.