Open-source • TypeScript • MIT License

Build AI agents
without lock-in

Stark-Kit is a lightweight, strictly typed, and provider-agnostic TypeScript framework for building AI agents. Write your agentic loops once and run them on OpenAI, Claude, Gemini, or Mistral — no rewrites, no lock-in.

Install

bash
bun add @mehularora/stark-kit zod

Peer dep: zod

Minimal Example

agent.ts
import "dotenv/config";
import { Agent, run, defineTool, ClaudeProvider } from "@mehularora/stark-kit";
import z from "zod";
const provider = new ClaudeProvider();
const weatherTool = defineTool({
name: "getWeather",
description: "Get the current weather for a city.",
parameters: z.object({
city: z.string().describe("The name of the city"),
}),
execute: async ({ city }) => {
return `The weather in ${city} is sunny and 22°C.`;
},
});
const agent = new Agent({
name: "WeatherBot",
provider,
instructions: "You are a helpful assistant. Keep answers brief.",
tools: [weatherTool],
});
const response = await run({ agent, messages: "What's the weather in Tokyo?" });
if (response.status === "complete") {
console.log(response.content);
}

Everything you need

Production-grade primitives, not a toy wrapper.

Strictly Typed Tools
Define tools with Zod schemas for full type-safety and runtime validation. Your IDE knows the shape of every argument.
Real-Time Streaming
Stream text deltas, tool call events, and lifecycle states with runStream to build responsive, live-updating UIs.
Lifecycle Hooks
Intercept LLM calls and tool executions with beforeChat, beforeTool, and afterTool hooks to sanitize, redact, or block.
Human-in-the-Loop
Mark tools with requiresApproval to pause execution. Resume with approve, reject, or modified arguments after review.
Agent Handoffs
Route requests between specialized agents at runtime. Build multi-agent networks with createHandoffTool.
Structured Outputs
Bind an agent to a Zod schema with outputType. The run loop enforces structured JSON responses automatically.

Supported providers

Switch providers by swapping a single constructor. Your agent code stays the same.

ProviderAdapter Class
OpenAIOpenAIProvider
ClaudeClaudeProvider
GeminiGeminiProvider
MistralMistralProvider