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 🙏

© 2025 – Pkg Stats / Ryan Hefner

groundswell

v0.0.1

Published

Hierarchical workflow orchestration engine with full observability

Readme

Groundswell

Hierarchical workflow orchestration engine with full observability.

Installation

npm install groundswell

Requirements: Node.js 18+, TypeScript 5.2+

Quick Start

Class-Based Workflow

import { Workflow, Step, ObservedState, WorkflowTreeDebugger } from 'groundswell';

class DataProcessor extends Workflow {
  @ObservedState()
  progress = 0;

  @Step({ trackTiming: true, snapshotState: true })
  async process(): Promise<string[]> {
    this.progress = 100;
    return ['item1', 'item2', 'item3'];
  }

  async run(): Promise<string[]> {
    this.setStatus('running');
    const result = await this.process();
    this.setStatus('completed');
    return result;
  }
}

const workflow = new DataProcessor('DataProcessor');
const debugger_ = new WorkflowTreeDebugger(workflow);

const result = await workflow.run();
console.log(debugger_.toTreeString());

Functional Workflow

import { createWorkflow } from 'groundswell';

const workflow = createWorkflow(
  { name: 'DataPipeline' },
  async (ctx) => {
    const loaded = await ctx.step('load', async () => fetchData());
    const processed = await ctx.step('process', async () => transform(loaded));
    return processed;
  }
);

const result = await workflow.run();

Agent with Prompt

import { createAgent, createPrompt } from 'groundswell';
import { z } from 'zod';

const agent = createAgent({
  name: 'AnalysisAgent',
  enableCache: true,
});

const prompt = createPrompt({
  user: 'Analyze this code for bugs',
  data: { code: 'function foo() { return 42; }' },
  responseFormat: z.object({
    bugs: z.array(z.string()),
    severity: z.enum(['low', 'medium', 'high']),
  }),
});

const result = await agent.prompt(prompt);
// result is typed as { bugs: string[], severity: 'low' | 'medium' | 'high' }

Documentation

  • Workflows - Hierarchical task orchestration
  • Agents - LLM execution with caching and reflection
  • Prompts - Type-safe prompt definitions with Zod

For AI Agents

Full documentation in a single file: llms_full.txt

Generate with npm run generate:llms

Core Concepts

Workflows

The primary orchestration unit. Manage execution status, emit events, and support hierarchical parent-child relationships. Two patterns are supported:

  • Class-based: Extend Workflow and override run()
  • Functional: Use createWorkflow() with an executor function

Agents

Lightweight wrappers around the Anthropic SDK. Execute prompts, manage tool invocation cycles, and integrate with caching and reflection systems.

Prompts

Immutable value objects defining what to send to an agent and how to validate the response using Zod schemas.

Decorators

// Emit lifecycle events and track timing
@Step({ trackTiming: true, snapshotState: true })
async processData(): Promise<void> { }

// Spawn and manage child workflows
@Task({ concurrent: true })
async createWorkers(): Promise<WorkerWorkflow[]> { }

// Mark fields for state snapshots
@ObservedState()
progress: number = 0;

@ObservedState({ redact: true })  // Shown as '***'
apiKey: string = 'secret';

Caching

LLM responses are cached using deterministic SHA-256 keys:

import { createAgent, defaultCache } from 'groundswell';

const agent = createAgent({ enableCache: true });

const result1 = await agent.prompt(prompt);  // API call
const result2 = await agent.prompt(prompt);  // Cached

console.log(defaultCache.metrics());  // { hits: 1, misses: 1, hitRate: 50 }

Reflection

Multi-level error recovery with automatic retry:

const workflow = createWorkflow(
  { name: 'MyWorkflow', enableReflection: true },
  async (ctx) => {
    await ctx.step('unreliable-operation', async () => {
      // If this fails, reflection will analyze and retry
    });
  }
);

Introspection Tools

Agents can inspect their position in the workflow hierarchy:

import { INTROSPECTION_TOOLS, createAgent } from 'groundswell';

const agent = createAgent({
  name: 'IntrospectionAgent',
  tools: INTROSPECTION_TOOLS,  // 6 tools for hierarchy navigation
});

Examples

npm run start:all              # Interactive runner
npm run start:basic            # Basic workflow
npm run start:decorators       # Decorator options
npm run start:parent-child     # Hierarchical workflows
npm run start:observers        # Observers and debugger
npm run start:errors           # Error handling
npm run start:concurrent       # Concurrent tasks
npm run start:agent-loops      # Agent loops
npm run start:sdk-features     # Tools, MCPs, hooks
npm run start:reflection       # Multi-level reflection
npm run start:introspection    # Introspection tools

See examples/ for source code.

API Reference

| Category | Exports | |----------|---------| | Core | Workflow, Agent, Prompt, MCPHandler | | Factories | createWorkflow, createAgent, createPrompt | | Decorators | @Step, @Task, @ObservedState | | Caching | LLMCache, defaultCache, generateCacheKey | | Reflection | ReflectionManager, executeWithReflection | | Introspection | INTROSPECTION_TOOLS, handleInspectCurrentNode, ... | | Debugging | WorkflowTreeDebugger, Observable |

Contributing

Contributions and issues are welcome.

Support

If Groundswell helps you build something great, consider fueling future development:

License

MIT