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

@sisu-ai/mw-react-parser

v9.0.0

Published

Lightweight ReAct-style tool loop. The model proposes an action in plain text, you parse it, execute a tool, then the model reflects and answers.

Readme

@sisu-ai/mw-react-parser

Lightweight ReAct-style tool loop. The model proposes an action in plain text, you parse it, execute a tool, then the model reflects and answers.

Tests CodeQL License Downloads PRs Welcome

Setup

npm i @sisu-ai/mw-react-parser

Exports

  • reactToolLoop() — returns middleware that performs one ReAct cycle as described.

What It Does

  • Think → Act → Observe → Reflect loop without provider‑specific function calling.
  • Parses Action: <tool> and Action Input: <json or text> from the assistant’s message.
  • Invokes a registered tool, feeds the observation back, and asks the model for a final answer.

How It Works

  • Calls model.generate(..., { toolChoice: 'none' }) to get an initial assistant message.
  • Extracts tool and args via regex; attempts JSON.parse on the input, falls back to raw text.
  • Executes the tool and appends a user message like Observation (tool): <result>.
  • Calls model.generate again (tools still disabled) and pushes the final assistant message.

This keeps the loop adapter‑agnostic and easy to reason about at the cost of relying on formatting.

Usage

import 'dotenv/config';
import { Agent, createConsoleLogger, InMemoryKV, NullStream, SimpleTools, type Ctx } from '@sisu-ai/core';
import { openAIAdapter } from '@sisu-ai/adapter-openai';
import { registerTools } from '@sisu-ai/mw-register-tools';
import { inputToMessage } from '@sisu-ai/mw-conversation-buffer';
import { reactToolLoop } from '@sisu-ai/mw-react-parser';

const model = openAIAdapter({ model: 'gpt-4o-mini' });

// Example tool
const webSearch = {
  name: 'webSearch',
  description: 'Search the web for a query',
  schema: { type: 'object', properties: { q: { type: 'string' } }, required: ['q'] },
  handler: async ({ q }: { q: string }) => ({ top: [`Result for ${q}`] })
};

const ctx: Ctx = {
  input: 'Find the npm page for @sisu-ai/core then summarize.',
  messages: [{ role: 'system', content: 'When helpful, decide an action using:\nAction: <tool>\nAction Input: <JSON>. Then reflect with the observation.' }],
  model,
  tools: new SimpleTools(),
  memory: new InMemoryKV(),
  stream: new NullStream(),
  state: {},
  signal: new AbortController().signal,
  log: createConsoleLogger({ level: 'info' })
};

const app = new Agent()
  .use(registerTools([webSearch as any]))
  .use(inputToMessage)
  .use(reactToolLoop());

Prompting Tips

  • Seed the system prompt with the required format, e.g.:
    • Use tools when helpful. Reply with:\nAction: <tool>\nAction Input: <JSON>
  • Keep tool schemas strict and arguments small to make parsing robust.

When To Use

  • You want a provider‑agnostic tool loop that works with any chat model.
  • You need a simple ReAct cycle without native function calling.

When Not To Use

  • You rely on provider‑native tools/function‑calling — prefer @sisu-ai/mw-tool-calling instead.
  • You need multi‑step or iterative planning — use iterativeToolCalling or a planner middleware.

Notes & Gotchas

  • Formatting sensitivity: parsing uses regex; poor formatting may fail to extract the action.
  • Security: validate tool inputs (zod) and guard tools with allow‑lists/capabilities.
  • Streaming: this middleware uses non‑streaming generate calls; pair with a streaming middleware if you need live tokens.

Community & Support

Discover what you can do through examples or documentation. Check it out at https://github.com/finger-gun/sisu. Example projects live under examples/ in the repo.