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-interface-analytics

v3.0.0-beta.95

Published

Analytics contract interfaces for the Robota SDK — usage snapshots, per-source totals and run-trace timelines

Readme

@robota-sdk/agent-interface-analytics

The usage and run-trace contracts of the Robota SDK: how many tokens a turn used, what it cost, which execution unit, model, provider and product surface it is attributed to, the per-turn timeline a trace view renders, and the cross-session personal-usage report.

The package contains type declarations only, with no classes and no runtime code. It declares the shape of a measurement; it measures nothing and decides no policy. It has no dependencies at all, not even @robota-sdk/agent-core.

Installation

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

Usage

A surface that shows the cost of a turn reads an IUsageSnapshot:

import type { IUsageSnapshot } from '@robota-sdk/agent-interface-analytics';

function formatUsage(usage: IUsageSnapshot): string {
  const cost =
    usage.costUsd === undefined
      ? 'cost unknown'
      : `${usage.costStatus === 'estimated' ? '~' : ''}$${usage.costUsd.toFixed(4)}`;
  return `${usage.totalTokens} tokens, ${usage.contextUsedPercentage}% of context, ${cost}`;
}

costStatus states confidence in the number, not success or failure: an unpriced model is unknown and has no costUsd, and a cost computed from a local price table is estimated.

What it defines

| Family | Main types | | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Per-turn usage | IUsageSnapshot, IUsageSource, IUsageObservation, IUsageModelShare, TUsageSurface | | Per-session report | IUsageBySourceReport, IUsageSourceTotals, IRunTraceTurn, IRunTraceSpan, ISpanEntry | | Live prompt trace | ILivePromptTraceBatch, IProviderCallTraceEntry, IToolBodyTraceEntry, IToolPermissionDecisionEntry | | Opt-in live content | ILivePromptContentPolicy, ILivePromptContentBatch, ILivePromptContentItem, ILivePromptContentToolRef, TLivePromptContentKind, TLivePromptContentOmitted | | Personal usage (7/30 days) | IPersonalUsageRequest, IPersonalUsageReport, IPersonalUsageTotals, IPersonalUsageDay, IPersonalUsageDimension, IPersonalUsageActivity, IPersonalUsageCoverage |

Usage, trace and personal-usage types carry counts, timings, identifiers and attribution only. Prompt, response, file path and tool payload text never appear in them.

Prompt, response and tool text is a separate, opt-in contract. A host states what it wants captured in an ILivePromptContentPolicy, and the text arrives in its own ILivePromptContentBatch, joined to the content-free trace only by the prompt's trace and span IDs. A consumer that never asks for content never holds any.

Where it sits

  • Depends on nothing.
  • @robota-sdk/agent-framework records usage observations and the live prompt trace (and, when a host opts in, live content) as a turn runs.
  • @robota-sdk/agent-session-analytics assembles reports: summarizeUsageBySource returns an IUsageBySourceReport, summarizePersonalUsage returns an IPersonalUsageReport.
  • @robota-sdk/agent-transport carries usage reports in its wire messages, and transports such as @robota-sdk/agent-transport-ws tag the turns they accept with a TUsageSurface.
  • @robota-sdk/agent-ui-terminal renders per-turn usage.
  • @robota-sdk/agent-interface-session names IUsageSnapshot and TUsageSurface in its turn and submit contracts.

Documentation

  • docs/SPEC.md — the contract, the boundaries, and why the package has no dependencies.

License

This package is dual-licensed under the GNU AGPL-3.0 or a commercial license. See LICENSING.md.