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

@telemetry-dev/pi

v0.2.9

Published

Pi coding-agent telemetry integration for telemetry.dev.

Readme

@telemetry-dev/pi

Telemetry integration for the pi coding agent and telemetry.dev. It records pi agent loops, model calls, tool executions, and lifecycle events without changing pi's behavior.

Docs: https://telemetry.dev/docs/integrations/pi

Install

pi install npm:@telemetry-dev/pi

This adds npm:@telemetry-dev/pi to the packages list in ~/.pi/agent/settings.json and installs it. Pi reads the package's pi.extensions manifest and loads @telemetry-dev/pi/register automatically.

Alternatively, install @telemetry-dev/pi where pi can resolve it and create ~/.pi/agent/extensions/telemetry-dev.ts:

import { telemetryDevExtension } from "@telemetry-dev/pi";
export default telemetryDevExtension();

Use one route, not both: if the package is in settings.json and also loaded from an extension file, pi loads the extension twice and every span is recorded twice.

Requires pi (@earendil-works/pi-coding-agent) 0.80.4 or later; tested with 0.82.1. The pi package is an optional peer dependency because pi bundles its extension API and provides it to installed extensions.

Environment

| Variable | Required | Default | Notes | | --------------------------- | -------- | --------------------------- | ----------------------------------------------------------------------- | | TELEMETRY_DEV_API_KEY | yes | — | Ingest key (td_live_…). No key ⇒ the integration is a complete no-op. | | TELEMETRY_DEV_BASE_URL | no | https://api.telemetry.dev | Trailing slashes are stripped. | | TELEMETRY_DEV_ENVIRONMENT | no | production | Environment label on every trace/log. | | OTEL_SERVICE_NAME | no | pi | OpenTelemetry service name. |

All four are also settable through SDK options when loading the extension directly:

Earlier versions sent data to https://ingest.telemetry.dev by default. That hostname reaches the same service and stays supported: if a firewall allows only it, set TELEMETRY_DEV_BASE_URL to it.

import { telemetryDevExtension } from "@telemetry-dev/pi";

export default telemetryDevExtension({
  agentName: "pair-programmer",
  captureInput: false,
  captureOutput: true,
});

Initialization is one-shot; the first extension factory initialized in a process supplies the SDK options.

Errors

The integration does not write to the terminal, because pi draws its TUI there. It appends SDK and extension errors to telemetry-dev.log in the pi agent directory: ~/.pi/agent, or PI_CODING_AGENT_DIR when you set it. The file has mode 0600. When the file is more than 5 MB, the integration moves it to telemetry-dev.log.1.

Writes happen in the background, so a slow disk does not hold up pi. When 100 entries are already waiting, later ones are dropped. session_shutdown waits up to one second for the queued entries.

A series of failed exports, for example during an ingest outage, is one entry. The next failure after an export reaches the ingest is a new entry.

To receive the errors in your code, pass onError to telemetryDevExtension(). The callback replaces the log file. To also write SDK diagnostics to the console, pass logLevel, for example "warn".

Trace shape

A typical session produces this hierarchy:

session
└── invoke_agent
    ├── chat {model}                  (assistant message)
    │   ├── execute_tool {toolName}   (tool calls from that message)
    │   └── execute_tool {toolName}
    └── chat {model}                  (final assistant message)
  • one session wrapper span for the full pi session;
  • one invoke_agent span for each prompt, with the prompt and the final assistant content;
  • one nested chat {model} span for each completed assistant message, with the provider, models, response id, finish reason, usage, pi cost, provider request, and all returned content blocks;
  • one execute_tool {toolName} span for each tool execution, under the chat span that issued the call. If no message matches the tool call id, the span is under the invoke_agent span. The span includes the tool call id, arguments, result, and error state;
  • lifecycle logs for sessions, turns, compaction, and model changes.

Each span and log reads ctx.sessionManager.getSessionId() when its event occurs. The span or log records the value as gen_ai.conversation.id. This keeps /new, /resume, /fork, and /reload events with the new session. Logs also have gen_ai.agent.name and the pi event type as eventName.

agent_end records the last run result and starts an asynchronous flush. agent_settled closes unfinished tool spans and the prompt span. session_shutdown closes an unfinished prompt and the session span, then waits for the final flush. It does not shut down the SDK during a pi session change.

Content capture

The prompt includes its image blocks. Chat input records the provider-formatted request from before_provider_request, after all context handlers and pi's model-message conversion. This conversion removes !! shell output and custom-message details from the model input. System instructions come from the effective ctx.getSystemPrompt() at the request boundary, after all before_agent_start handlers. Chat output contains all returned content blocks. The integration also records tool arguments and tool results.

These values obey the telemetry.dev SDK captureInput and captureOutput settings, which default to true. Use mask to remove values before capture. Use maxAttributeLength to limit serialized attributes.

The SDK records an exception message only when both captureInput and captureOutput are on, and passes it through mask. With both on and no mask, a failed tool's result text is also its exception message. With a mask set, the exception message is tool <name> failed, and the result text stays in the tool output, which follows captureOutput and mask. A failed assistant message's errorMessage is a provider diagnostic, not tool output: chat and agent spans use it as the exception message also when a mask is set, and the mask receives it.

Limitations

  • Chat input uses each provider's request shape, not pi's raw session messages. Pi's public hooks do not expose the final wire payload. A later before_provider_request handler can replace the request after capture. Custom providers must call pi's onPayload callback for request and system instruction capture. Without that callback, those fields are absent. Prompt, output, and tool capture still work.
  • Pi does not expose per-request TTFT or duration fields. Chat duration is measured from message_start to message_end using local wall-clock time, and TTFT is not recorded.
  • tool_call and tool_result are intentionally not intercepted. In pi, an uncaught tool_call handler error blocks the user's tool, so this integration uses the fail-open tool_execution_start / tool_execution_end events instead.
  • An assistant message with stopReason: "aborted" is recorded with finish reason aborted, not as an error. Only stopReason: "error" marks chat and agent spans as errors.
  • gen_ai.usage.cost is pi's client-side USD estimate from its bundled model pricing, not a charge or server-calculated invoice value.
  • Initialization is one-shot. Loading the package more than once does not replace the first configuration.

License

MIT. See LICENSE.