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

agentlens-sdk

v0.2.8

Published

AgentLens TypeScript SDK — Agent observability that traces decisions, not just API calls.

Readme

agentlens-sdk

TypeScript SDK for AgentLens — Agent observability that traces decisions, not just API calls.

npm version license

Install

npm install agentlens-sdk

Quick Start

First, create an account at agentlens.vectry.tech/register and generate an API key in Settings > API Keys in the dashboard.

import { init, TraceBuilder, shutdown } from "agentlens-sdk";

// Initialize with the API key from Settings > API Keys
init({
  apiKey: "your-api-key",
  endpoint: "https://agentlens.vectry.tech/api",
});

// Create a trace
const trace = new TraceBuilder("agent-run-123", "My Agent Task");

// Add a span (tool call, LLM call, etc.)
trace.addSpan({
  name: "search-documents",
  type: "tool",
  input: { query: "quarterly report" },
  output: { results: 5 },
});

// Record a decision point
trace.addDecision({
  name: "select-tool",
  type: "tool_selection",
  options: ["search", "calculate", "summarize"],
  selected: "search",
  reasoning: "User asked for document lookup",
});

// Finalize and send
await trace.end();

// Flush remaining data before exit
await shutdown();

API Reference

Core Functions

| Function | Description | |---|---| | init(options) | Initialize the SDK with your API key and configuration. | | shutdown() | Flush pending data and shut down the transport. | | flush() | Manually flush the current batch without shutting down. | | getClient() | Return the initialized client instance. |

TraceBuilder

The primary interface for constructing traces.

const trace = new TraceBuilder(traceId: string, name: string);

trace.addSpan(span: SpanPayload);       // Add a span to the trace
trace.addDecision(decision: DecisionPointPayload); // Record a decision point
trace.end(): Promise<void>;             // Finalize and send the trace

Standalone Helpers

| Function | Description | |---|---| | createDecision(decision) | Create and send a standalone decision point outside a trace. |

Types

Core payload types used throughout the SDK:

  • TracePayload — Top-level trace structure containing spans and metadata.
  • SpanPayload — Individual unit of work (tool call, LLM request, retrieval, etc.).
  • DecisionPointPayload — A recorded decision: what options existed, what was chosen, and why.
  • EventPayload — Discrete event within a span or trace.
  • JsonValue — Flexible JSON-compatible value type for inputs/outputs.

Enums

| Enum | Values | |---|---| | TraceStatus | Status of the overall trace (e.g., running, completed, failed). | | SpanType | Category of span (e.g., tool, llm, retrieval). | | SpanStatus | Status of an individual span. | | DecisionType | Category of decision (e.g., tool_selection, routing). | | EventType | Category of event within a span. |

Configuration

Pass InitOptions to init():

init({
  apiKey: "your-api-key",       // Required. Create at Settings > API Keys in the dashboard.
  endpoint: "https://...",      // API endpoint. Defaults to AgentLens cloud.
  maxBatchSize: 100,            // Max items per batch before auto-flush.
  flushInterval: 5000,          // Auto-flush interval in milliseconds.
});

You can also set the API key via the AGENTLENS_API_KEY environment variable instead of passing it directly.

Transport

The SDK ships with BatchTransport, which batches payloads and flushes them on an interval or when the batch size threshold is reached. This is used internally by init() — you typically do not need to instantiate it directly.

Billing

Each trace counts as one session for billing. AgentLens cloud offers three tiers:

| Plan | Price | Sessions | |------|-------|----------| | Free | $0 | 20 sessions/day | | Starter | $5/month | 1,000 sessions/month | | Pro | $20/month | 100,000 sessions/month |

Manage your subscription in Settings > Billing. Self-hosted instances have no session limits.

Documentation

Full documentation: agentlens.vectry.tech/docs/typescript-sdk

License

MIT