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

@robota-sdk/agent-session-analytics

v3.0.0-beta.93

Published

Session-log timing analysis and reporting for the Robota SDK (analyzeSession, aggregateReports, report formatters)

Readme

@robota-sdk/agent-session-analytics

Timing and usage analysis over persisted agent session records.

Given session records, it computes per-turn timing intervals (LLM wait vs. tool execution), attributes token usage and cost to the source that spent it (main thread, subagents, background tasks, tools, commands, skills), aggregates cross-session personal usage into complete local-calendar days, projects usage into OpenTelemetry (OTLP) payloads, and renders text reports. Everything is a pure function: no file I/O, no process.*, no network. Callers load the records and write or send the output; a host CLI's usage command is one such caller.

Installation

npm install @robota-sdk/agent-session-analytics

Usage

import {
  analyzeSession,
  formatSingleSession,
  formatUsageReport,
  summarizeUsageBySource,
} from '@robota-sdk/agent-session-analytics';
import type { IInteractiveSessionRecord } from '@robota-sdk/agent-interface-session';

declare const record: IInteractiveSessionRecord; // loaded by the caller

process.stdout.write(formatSingleSession(analyzeSession(record)) + '\n');
process.stdout.write(formatUsageReport(summarizeUsageBySource(record)) + '\n');

API

Timing

| Export | Description | | --------------------------- | ---------------------------------------------------- | | analyzeSession(record) | Compute the timing report for one session record | | aggregateReports(reports) | Aggregate multiple single-session reports | | computeTimingIntervals(h) | Classify a history array into timing intervals | | gapMs(from, to) | Millisecond gap between two timestamps (string/Date) | | formatSingleSession(r) | Render a single-session report as text | | formatAggregateReport(a) | Render an aggregate report as text |

Usage and cost

| Export | Description | | ----------------------------------- | ----------------------------------------------------------------------------------- | | summarizeUsageBySource(record) | Token and cost totals per source, the top consumer, and the per-turn span timeline | | formatUsageReport(report) | Render the per-source usage report as text | | summarizePersonalUsage(snapshot) | Build a deterministic 7- or 30-day personal-usage report from an immutable snapshot | | formatPersonalUsageReport(report) | Render the personal-usage report as text |

OTLP export

These build OTLP/JSON payloads from session records; sending them to a collector is the caller's job (a host CLI's usage export command does it). The payloads are content-free: no prompt or reply text, no session identity.

| Export | Description | | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | | createOtlpUsageSnapshot(records, at, version) | Usage metrics as Gauges, so re-exporting a snapshot never counts the same usage twice | | createOtlpPromptRootTraces(records, version) | Prompt-root trace spans, only for roots whose identity validates; returns coverage counts for what it skipped | | createOtlpPromptEvents(records, version, observedAt) | One outcome-only completion log event per accepted span |

Unknown cost or token splits stay visible as unknown rather than being reported as zero.

The record and history types are the canonical IInteractiveSessionRecord and IHistoryEntry; this package defines no duplicates. The usage and trace report types (IUsageBySourceReport, IUsageSourceTotals, IRunTraceSpan, IRunTraceTurn) are owned by @robota-sdk/agent-interface-analytics and re-exported here for convenience.

See docs/SPEC.md for the full contract.