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

@aidex/observability

v1.1.0

Published

Aidex Observability — reusable execution metrics, timeline, cost estimation, and logging utilities. Not a Plugin itself.

Downloads

1,656

Readme

@aidex/observability

Installation

pnpm add @aidex/observability
npm install @aidex/observability

Reusable observability utilities for Aidex: measuring execution duration, collecting an ordered event timeline, estimating token cost, and logging a strategy's start/finish safely. This package is not a Plugin — it has no dependency on Plugin, Lifecycle, or Aidex at all. It is meant to be consumed by a future observability Plugin (in @aidex/plugins), which would compose these primitives around the beforeExecute/afterExecute hooks.

Contents

  • metrics/ExecutionMetrics — pure duration calculation: recordStart(), recordEnd(), getDuration(). No logging, no persistence, no timestamp generated unless the caller omits one.
  • timeline/Timeline — an ordered, caller-driven event collector. Never generates its own timestamp; only preserves insertion order for whatever ObservabilityEvents the caller records (e.g. started, provider-called, provider-returned, strategy-finished).
  • cost/CostEstimator (estimateCost) — pure math over { inputTokens, outputTokens, inputPricePerMillion, outputPricePerMillion }. No hardcoded vendor pricing table of any kind — the caller supplies prices.
  • logger/ExecutionLogger — a thin, safe ILogger wrapper for a strategy's start/finish. Never throws, even if the supplied logger itself throws or is undefined.
  • types/ObservabilityEvent — the shared event shape ({ event, metadata? }) Timeline records. Deliberately generic — no provider, vendor, or application field of any kind.
  • bus/ObservabilityBus — the unified event system: subscribe(handler) (returns an unsubscribe function) / emit(event), backed by a Timeline for ordered history (getTimeline()). Eight named track*() convenience methods cover every signal this package tracks — trackTokens, trackCost, trackDuration, trackProvider, trackEngine, trackWorkflow, trackError, trackRetry — each just emit()ing a well-known event name (ObservabilityEventName) with caller-supplied metadata. trackCostFromEstimate()/trackDurationFromMetrics() tie the bus to the existing estimateCost()/ExecutionMetrics rather than duplicating their math.

Independence

This package knows nothing about Gemini, OpenAI, Claude, Ollama, Design Platform, Print Platform, or any other application or vendor. It only observes execution in the abstract — durations, ordered events, token-based cost math, and log lines — and every one of those inputs is supplied by the caller.

Architecture rules this package follows

  • Composition only — no inheritance, no abstract base class, no class hierarchy anywhere in this package.
  • No singletons, no global mutable state — every class is instantiated by its caller and holds only its own instance state.
  • Pure functions where state isn't needed (estimateCost); small focused classes where it is (ExecutionMetrics, Timeline, ExecutionLogger).
  • src/index.ts exports the public utilities and their I/O types only.

Dependency direction

@aidex/observability depends on @aidex/core only (for ILogger). It does not depend on, and must never depend on, @aidex/providers, @aidex/strategies, @aidex/plugins, or any future workflow/memory/sdk package.