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

@loopstack/workflow-state-example-workflow

v0.21.3

Published

A workflow demonstrating how to interact with custom state of a workflow

Downloads

622

Readme

@loopstack/workflow-state-example-workflow

A module for the Loopstack AI automation framework.

This module provides an example workflow demonstrating how to manage state across transitions using instance properties.

Overview

The Workflow State Example Workflow shows how to store data as instance properties and access it across transitions. It demonstrates the core patterns for managing data flow in a workflow.

By using this workflow as a reference, you'll learn how to:

  • Store tool results as workflow instance properties
  • Access instance properties in subsequent transitions
  • Create private helper methods to transform stored data
  • Use @InjectTool() to declare and call tools

This example is useful for developers building workflows that need to store and manipulate data across transitions.

Installation

See SETUP.md for installation and setup instructions.

How It Works

Key Concepts

1. Defining Workflow State

State is stored as instance properties on the workflow class. No special decorator is needed -- just declare properties on your class:

@Workflow({
  uiConfig: __dirname + '/workflow-state.ui.yaml',
})
export class WorkflowStateWorkflow extends BaseWorkflow {
  @InjectTool() private createValue: CreateValue;
  @InjectTool() private createChatMessage: CreateChatMessage;

  message?: string;
}

The message property is a plain instance property that persists across transitions automatically.

2. Storing Tool Results in State

Call a tool and assign the result to an instance property inside a transition method:

@Initial({ to: 'data_created' })
async createSomeData() {
  const result = await this.createValue.call({ input: 'Hello :)' });
  this.message = result.data as string;
}

The createValue tool returns a ToolResult with a data property. The value is stored in this.message for use in later transitions.

3. Accessing State in Later Transitions

Instance properties are available in any subsequent transition method:

@Final({ from: 'data_created' })
async showResults() {
  await this.createChatMessage.call({
    role: 'assistant',
    content: `Data from state: ${this.message}`,
  });

  await this.createChatMessage.call({
    role: 'assistant',
    content: `Use workflow helper method: ${this.messageInUpperCase(this.message!)}`,
  });
}

4. Private Helper Methods

Define private methods to transform or process state data:

private messageInUpperCase(message: string): string {
  return message?.toUpperCase();
}

These are standard TypeScript methods with no decorator required. Call them from any transition using this.messageInUpperCase(...).

Complete Workflow

import { BaseWorkflow, Final, Initial, InjectTool, Workflow } from '@loopstack/common';
import { CreateChatMessage } from '@loopstack/create-chat-message-tool';
import { CreateValue } from '@loopstack/create-value-tool';

@Workflow({
  uiConfig: __dirname + '/workflow-state.ui.yaml',
})
export class WorkflowStateWorkflow extends BaseWorkflow {
  @InjectTool() private createValue: CreateValue;
  @InjectTool() private createChatMessage: CreateChatMessage;

  message?: string;

  @Initial({ to: 'data_created' })
  async createSomeData() {
    const result = await this.createValue.call({ input: 'Hello :)' });
    this.message = result.data as string;
  }

  @Final({ from: 'data_created' })
  async showResults() {
    await this.createChatMessage.call({
      role: 'assistant',
      content: `Data from state: ${this.message}`,
    });

    await this.createChatMessage.call({
      role: 'assistant',
      content: `Use workflow helper method: ${this.messageInUpperCase(this.message!)}`,
    });
  }

  private messageInUpperCase(message: string): string {
    return message?.toUpperCase();
  }
}

Dependencies

This workflow uses the following Loopstack modules:

  • @loopstack/common - Base classes, decorators, and tool injection
  • @loopstack/create-chat-message-tool - Provides CreateChatMessage tool
  • @loopstack/create-value-tool - Provides CreateValue tool

About

Author: Jakob Klippel

License: Apache-2.0

Additional Resources