loupe-ai
v0.0.83
Published
A magnifying glass for your AI agent — TypeScript SDK.
Maintainers
Readme
loupe-ai — TypeScript SDK
A magnifying glass for your AI agent. TypeScript counterpart of the Python loupe-ai package — same wire format, same ~/.loupe/traces/ directory, same loupe ui dashboard.
npm install loupe-aiQuickstart
import { trace, recordStep } from "loupe-ai";
const myAgent = trace({ framework: "ai-sdk" }, async (q: string) => {
recordStep("thought", "plan", { outputs: { plan: "..." } });
return await someLLMCall(q);
});
await myAgent("refactor auth.ts");
// trace written to ~/.loupe/traces/{trace_id}.jsonlThen in another terminal:
pip install loupe-ai
loupe ui # forensic dashboard shows your TS traceVercel AI SDK integration
import { generateText } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { trace } from "loupe-ai";
import { wrapModel } from "loupe-ai/ai-sdk";
const model = wrapModel(anthropic("claude-sonnet-4-6"));
const myAgent = trace({ framework: "ai-sdk" }, async (q: string) => {
const { text } = await generateText({ model, prompt: q });
return text;
});Or middleware-style:
import { wrapLanguageModel } from "ai";
import { loupeMiddleware } from "loupe-ai/ai-sdk";
const model = wrapLanguageModel({
model: anthropic("claude-sonnet-4-6"),
middleware: loupeMiddleware(),
});Zero-code capture
No imports at all — preload the autopatch hook and every supported SDK call in the process is traced:
NODE_OPTIONS="--require loupe-ai/autopatch" node agent.jsDev setup (from the repo)
cd packages/loupe-ts
npm install
npm test # vitest
npm run build # tsup → dist/