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

@codmir/events

v2.0.0

Published

Event system for UI & backend activity tracking, AI-safe workflows, logging, error detection, and replay

Readme

@codmir/events

Event system SDK for observability, telemetry, AI task scheduling, and workflow automation.

Features

  • Telemetry — Batch event reporting to Codmir Events Platform with retries
  • Event Bus Client — Publish/subscribe to events across services
  • AI Task Scheduler — Schedule and delegate tasks between AI agents
  • Workflow Schema — Visual workflow definitions with 8 node types
  • Core Event System — Typed events, monitoring, logging, replay
  • NestJS Integration — Ready-to-use modules and decorators

Installation

pnpm add @codmir/events

Telemetry (Recommended)

Track events from any project and report them to the Codmir Events Platform.

import { createTelemetry } from '@codmir/events/telemetry';

const telemetry = createTelemetry({
  endpoint: 'https://codmir.com/api/events/ingest',
  apiKey: process.env.CODMIR_EVENTS_API_KEY,
  projectId: 'proj_123',
  source: 'my-app',
  environment: 'production',
  // Optional
  batchSize: 25,        // flush after 25 events (default)
  flushIntervalMs: 5000, // auto-flush every 5s (default)
  maxRetries: 3,        // retry on 5xx errors (default)
  debug: false,         // console logging (default)
});

// Track a simple event
telemetry.track('user/signed-up', { userId: '123', plan: 'pro' });

// Track with options
telemetry.track('order/created', { orderId: 'ord_1', total: 99 }, {
  correlationId: 'checkout_abc',
  userId: 'user_456',
});

// Track an operation with automatic timing
const op = telemetry.trackOperation('deploy/build', { branch: 'main' });
await runBuild();
op.end(); // records COMPLETED + durationMs

// Handle errors
const op2 = telemetry.trackOperation('email/send');
try {
  await sendEmail();
  op2.end();
} catch (err) {
  op2.end({ error: err.message }); // records FAILED + error
}

// Manual flush
await telemetry.flush();

// Graceful shutdown (flushes remaining queue)
await telemetry.shutdown();

Telemetry Config

| Option | Type | Default | Description | |--------|------|---------|-------------| | endpoint | string | required | Ingestion API URL | | apiKey | string | — | Bearer token for auth | | projectId | string | — | Associate events with a project | | organizationId | string | — | Associate with an organization | | source | string | — | Source identifier (e.g. "my-app") | | environment | string | — | e.g. "production", "staging" | | batchSize | number | 25 | Events per batch before auto-flush | | flushIntervalMs | number | 5000 | Auto-flush interval (ms) | | maxRetries | number | 3 | Retries for server errors | | debug | boolean | false | Enable console logging | | headers | object | — | Custom request headers |

Event Bus Client

Publish and subscribe to events via the Codmir event bus.

import { createEventClient } from '@codmir/events/client';

const client = createEventClient({
  serviceUrl: 'http://localhost:3000',
  agentId: 'my-service',
  projectId: 'proj_123',
});

// Publish
await client.publish({
  type: 'ticket/created',
  data: { ticketId: 't_1', title: 'Fix login bug' },
});

// Subscribe
await client.subscribe(['task.completed', 'task.failed'], (event) => {
  console.log('Event:', event.type, event.data);
});

// Cleanup
client.close();

AI Task Scheduler

Coordinate AI agents with role-based task queuing.

import { createTaskScheduler } from '@codmir/events/scheduler';

const scheduler = createTaskScheduler({
  serviceUrl: 'http://localhost:3000',
  projectId: 'proj_123',
});

// Register as an agent
await scheduler.registerAgent({
  name: 'Coder AI',
  role: 'coder',
  capabilities: ['typescript', 'react'],
});

// Process tasks
await scheduler.startProcessing(async (task) => {
  const result = await generateCode(task.input);
  return { status: 'completed', output: { code: result } };
});

Agent Roles

| Role | Description | |------|-------------| | coordinator | Orchestrates agents, breaks down tasks | | coder | Writes and modifies code | | reviewer | Reviews code and provides feedback | | tester | Creates and runs tests | | documenter | Writes documentation | | researcher | Researches and gathers information | | planner | Creates plans and architecture | | debugger | Debugs and fixes issues | | security | Security analysis and fixes | | devops | Infrastructure and deployment |

Workflow Schema

Define visual workflows with typed nodes and edges (used in the workflow builder).

import {
  WorkflowDefinitionSchema,
  WORKFLOW_TEMPLATES,
  createWorkflowFromTemplate,
  validateWorkflow,
} from '@codmir/events';

// Create from template
const workflow = createWorkflowFromTemplate(
  'ticket-to-code', 'proj_123', 'org_456', 'user_789'
);

// Validate
const { valid, errors } = validateWorkflow(workflow);

Node Types

| Type | Description | Color | |------|-------------|-------| | trigger | Event or schedule start | Amber | | action | HTTP, DB, integration | Blue | | ai | LLM call or AI task | Purple | | condition | Branching logic (true/false) | Orange | | wait | Delay or timer | Cyan | | agent | Delegate to AI agent | Indigo | | transform | Data transformation | Teal | | output | Workflow result | Emerald |

Subpath Exports

import { ... } from '@codmir/events';           // Core + telemetry re-exports
import { ... } from '@codmir/events/telemetry';  // CodmirTelemetry, createTelemetry
import { ... } from '@codmir/events/client';      // EventClient, createEventClient
import { ... } from '@codmir/events/scheduler';   // TaskScheduler
import { ... } from '@codmir/events/orchestrator'; // Multi-agent orchestrator
import { ... } from '@codmir/events/core';        // Core types and factory
import { ... } from '@codmir/events/monitoring';  // Monitoring system
import { ... } from '@codmir/events/logging';     // Structured logging
import { ... } from '@codmir/events/replay';      // Event replay
import { ... } from '@codmir/events/adapters';    // Transport adapters
import { ... } from '@codmir/events/nestjs';      // NestJS modules
import { ... } from '@codmir/events/preview';     // IDE preview system
import { ... } from '@codmir/events/domains';     // Domain event types

Environment Variables

# Telemetry
CODMIR_EVENTS_API_KEY=your-api-key
CODMIR_EVENTS_ENDPOINT=https://codmir.com/api/events/ingest

# Event bus (legacy)
EVENTS_SERVICE_URL=http://localhost:3000
AGENT_ID=unique-agent-id
PROJECT_ID=project-123
ORGANIZATION_ID=org-456

License

MIT