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

@agent-relay/events

v7.1.1

Published

![Agent Relay](../../readme-banner.png)

Readme

Agent Relay

@agent-relay/events

Normalized event stream for proactive agents — Layer 2 of the Agent Relay runtime.

npm License

Website: agentrelay.com · Docs: agentrelay.com/docs

What it does

@agent-relay/events turns the three proactive primitives (cron, watch, inbox) into one normalized event stream. Subscribe with a single onEvent handler; receive lightweight envelopes that you can lazily expand() to full payloads.

It is the transport-agnostic core: no workspace concept, no scheduling, no cloud assumptions — pure event stream plus retry policy plus OpenTelemetry tracing. Compose it directly for hosted webhooks, or build a higher-level runtime on top (see @agent-relay/agent).

Install

npm install @agent-relay/events

Quick start

import { events } from '@agent-relay/events';

const handle = events({
  workspace: 'support',
  apiKey: process.env.RELAY_API_KEY!,
  onEvent: async (event) => {
    console.log(event.type, event.resource.path);

    const full = await event.expand('full');
    // ... act on full.data
  },
});

// ... later
await handle.stop();

Event envelope shape

Every event arrives as a normalized AgentEvent:

type AgentEvent = {
  id: string;                           // stable event id
  workspace: string;
  type: 'cron.tick' | 'startup' | 'relayfile.changed' | 'relaycast.message' | ...;
  occurredAt: string;                   // ISO timestamp
  attempt: number;                      // delivery attempt count
  resource: { path: string; kind: string; id: string; provider: string };
  summary: EventSummary;                // <1KB, PII-stripped
  expand: (level: 'summary' | 'full' | 'diff' | 'thread') => Promise<Expansion>;
  digest?: string;
};

The envelope is the shape your handler receives — not the full provider payload. Call event.expand('full') to materialize the resource lazily.

Expansion levels

| Level | What you get | Cost | | --------- | ------------------------------------------------------- | ----------------- | | summary | Pre-included lightweight summary (already on the event) | free | | full | Full canonical resource via gateway / relayfile VFS | one read | | diff | Changed fields vs prior state | one read | | thread | Paginated comments / replies | one or more reads |

Retry + NoRetry sentinel

import { events, NoRetry } from '@agent-relay/events';

events({
  workspace: 'support',
  apiKey: process.env.RELAY_API_KEY!,
  onEvent: async (event) => {
    try {
      // ... your work
    } catch (err) {
      if (isPermanent(err)) throw new NoRetry(err); // skip retry queue
      throw err; // 5-attempt exp backoff
    }
  },
});

OpenTelemetry

Every dispatched event is wrapped in a SpanKind.CONSUMER span tagged with the event id, type, workspace, and attempt. Configure your exporter (e.g. OTEL_EXPORTER_OTLP_ENDPOINT) — @agent-relay/events plugs into the global tracer provider via @opentelemetry/api.

Related

License

Apache-2.0 — see LICENSE.