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

@tracegraph/scenario-runner

v0.3.1

Published

Scenario runner and TraceBundle linker for TraceGraph

Readme

@tracegraph/scenario-runner

Multi-service scenario orchestrator for TraceGraph. Reads a declarative scenario definition file, starts the required servers, executes HTTP steps in order (injecting correlation headers on every request), collects the resulting traces, and links them into a TraceBundle — a single artifact that ties together all cross-service calls from one scenario run.

Used internally by the tracegraph scenario run CLI command.

What's in this package

| Export | Description | |--------|-------------| | runScenario(definition, options) | Main entry point — orchestrates the full scenario: start servers → execute steps → stop servers → create bundle | | loadScenarioDefinition(filePath) | Reads and validates a .scenario.json file | | ServerManager | Manages server process lifecycle (spawn, health check, shutdown) | | executeStep(step, context) | Executes a single HTTP step and returns the response + trace correlation data | | createBundle(traces, scenario) | Links a set of TraceSession objects into a TraceBundle via correlation IDs | | ScenarioRunOptions | Options for runScenario (output directory, timeout, dry-run) | | ServerHandle | Handle returned by ServerManager.start() — used to await health checks and stop the server | | StepContext | Context passed to executeStep containing the correlation ID, headers, and base URLs |

Installation

npm install @tracegraph/scenario-runner

Usage

Running a scenario programmatically

import { runScenario, loadScenarioDefinition } from '@tracegraph/scenario-runner';

const definition = loadScenarioDefinition('.tracegraph/scenarios/create-invoice.scenario.json');

const bundle = await runScenario(definition, {
  outputDir: '.tracegraph/bundles',
  timeoutMs: 30_000,
});

console.log(`Bundle: ${bundle.bundleId}`);
console.log(`Traces: ${bundle.traceIds.join(', ')}`);

Scenario definition format

Scenario files are JSON (.tracegraph/scenarios/*.scenario.json):

{
  "schemaVersion": "tracegraph.scenario.v1",
  "scenarioId":   "create_invoice",
  "name":         "Create Invoice — end-to-end",
  "servers": [
    {
      "name":    "express-api",
      "command": "node -r ts-node/register src/app.ts",
      "port":    3001,
      "env":     { "PORT": "3001" },
      "healthCheck": {
        "path":           "/health",
        "expectedStatus": 200,
        "intervalMs":     300
      }
    }
  ],
  "steps": [
    {
      "name": "Create invoice",
      "http": {
        "method": "POST",
        "url":    "http://localhost:3001/invoices",
        "body":   { "customerId": "c1", "amount": 150 }
      },
      "assert": { "status": 201 }
    },
    {
      "name": "List invoices",
      "http": {
        "method": "GET",
        "url":    "http://localhost:3001/invoices"
      },
      "assert": { "status": 200, "bodyContains": "c1" }
    }
  ],
  "tags": ["smoke"]
}

Correlation headers

The runner automatically injects two headers on every HTTP step:

| Header | Value | Purpose | |--------|-------|---------| | x-tracegraph-scenario-id | <scenarioId> | Tags all requests to the same scenario run | | x-tracegraph-correlation-id | <scenarioId>_step<N> | Links outbound calls across service boundaries |

The receiving service's TraceGraph adapter reads x-tracegraph-correlation-id and stores it on the http_request event as causalParentRef, allowing createBundle to stitch cross-service traces together.

Using bundles with tracegraph compare

tracegraph compare --bundle .tracegraph/bundles/create_invoice_run_abc.bundle.json

The compare command reads every traceId referenced in the bundle and compares each against its corresponding baseline.

CLI equivalent

Everything in this package is also accessible via the CLI:

# Run a scenario
tracegraph scenario run .tracegraph/scenarios/create-invoice.scenario.json

# Validate without running
tracegraph scenario validate .tracegraph/scenarios/create-invoice.scenario.json

# List all scenario files
tracegraph scenario list