npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-agent-trace

v0.1.2

Published

Structured logger and CLI visualizer for AI agent traces (LLM calls, tool calls, reasoning)

Readme

ai-agent-trace

npm

Structured logger and CLI timeline viewer for AI agent traces. Logs LLM calls, tool calls, and reasoning steps to JSONL files, then renders them as a color timeline in your terminal.

No external dependencies — just Node built-ins and raw ANSI codes.

Install

npm install ai-agent-trace
# or globally for the CLI
npm install -g ai-agent-trace

Logger API

import { AgentTracer } from "ai-agent-trace";

const tracer = new AgentTracer({
  outputFile: "trace.jsonl",
  sessionId: "run-001", // optional — auto-generated UUID if omitted
});

// Group events into a step
tracer.startStep("gather context");

// Log an LLM call
tracer.logLLMCall({
  prompt: "Summarize this document...",
  response: "The document covers...",
  model: "claude-sonnet-4-6",
  inputTokens: 1200,
  outputTokens: 340,
  durationMs: 1850,
});

// Log a tool call
tracer.logToolCall({
  toolName: "bash",
  input: { command: "ls -la" },
  output: "total 32\n-rw-r--r-- ...",
  durationMs: 45,
  // error: "ENOENT"  // optional — highlight red in viewer
});

// Log agent reasoning / thinking
tracer.logReasoning({
  text: "I need to read the file before editing it.",
});

tracer.endStep();

Integration example with Anthropic SDK

import Anthropic from "@anthropic-ai/sdk";
import { AgentTracer } from "ai-agent-trace";

const client = new Anthropic();
const tracer = new AgentTracer({ outputFile: "trace.jsonl" });

tracer.startStep("user request");

const start = Date.now();
const message = await client.messages.create({
  model: "claude-sonnet-4-6",
  max_tokens: 1024,
  messages: [{ role: "user", content: "What files are in the current directory?" }],
});

const responseText = message.content
  .filter((b) => b.type === "text")
  .map((b) => b.text)
  .join("");

tracer.logLLMCall({
  prompt: "What files are in the current directory?",
  response: responseText,
  model: message.model,
  inputTokens: message.usage.input_tokens,
  outputTokens: message.usage.output_tokens,
  durationMs: Date.now() - start,
});

tracer.endStep();

CLI

agent-trace view <file.jsonl> [options]

Options

| Flag | Description | | ------- | ----------- | | --full | Show complete prompt/response without truncation | | --filter <type> | Show only: llm_call | tool_call | reasoning | step_start | step_end | | --session <id> | Filter to a specific session ID |

Example output

┌─ STEP: gather context ──────────────────────────────────
12:00:01 ◆ LLM claude-sonnet-4-6  1.85s  tokens: 1200↑ 340↓
  prompt: Summarize this document...
  response: The document covers...
12:00:02 ⚙ TOOL bash  45ms  ✓
  input: {"command":"ls -la"}
  output: "total 32\n-rw-r--r-- ..."
12:00:02 ◎ think I need to read the file before editing it.
└─ end gather context  1.90s

════════════════════════════════════════════════════════════
SUMMARY
  sessions:   run-001
  llm calls:  1
  tool calls: 1
  errors:     0
  tokens in:  1200
  tokens out: 340
  duration:   1.90s
════════════════════════════════════════════════════════════

JSONL Schema

Each line is one JSON event:

interface BaseEvent {
  id: string;          // UUID
  timestamp: string;   // ISO 8601
  sessionId: string;
  type: "llm_call" | "tool_call" | "reasoning" | "step_start" | "step_end";
  payload: LLMCallPayload | ToolCallPayload | ReasoningPayload | StepStartPayload | StepEndPayload;
}

See src/types.ts for full type definitions.

Development

npm run build       # compile with tsup
npm test            # run vitest suite
npm run typecheck   # tsc --noEmit

License

MIT