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

melony

v0.3.0

Published

Fast, unopinionated, minimalist event-based framework for AI agents.

Readme

melony

Fast, unopinionated, minimalist event-based framework for AI agents.

Installation

npm install melony

🔥 New: Fluent Builder API (Recommended)

import { melony } from "melony";

const agent = melony()
  .on("user:text", async function* (event, { runtime }) {
    if (event.data.content.includes("weather")) {
      yield { type: "assistant:text", data: { content: "Weather in London is 24°C" } };
    }
  });

// Run it (or use agent.streamResponse(event) for HTTP)
for await (const event of agent.build().run({ type: "user:text", data: { content: "How's the weather?" } })) {
  console.log(event);
}

Legacy: Runtime Class API (Still Supported)

import { Runtime } from "melony";

// 1. Create the runtime
const agent = new Runtime({
  eventHandlers: new Map([
    ["user:text", [async function* (event, { runtime }) {
      if (event.data.content.includes("weather")) {
        yield { type: "assistant:text", data: { content: "Weather in London is sunny!" } };
      }
    }]]
  ])
});

Fluent Builder API

The fluent builder provides an excellent developer experience with method chaining:

Event Handlers

const agent = melony()
  .on("user:text", async function* (event, { runtime }) {
    // Intercept and handle events
    if (event.data.content.includes("help")) {
      yield { type: "assistant:text", data: { content: "How can I help you?" } };
    }
  })
  .on("assistant:text", async function* (event) {
    console.log(`Agent said: ${event.data.content}`);
  })
  .build();

Plugin System

Plugins allow you to modularize and reuse handlers across different agents. A plugin is simply a function that receives the MelonyBuilder.

import { melony, MelonyPlugin } from "melony";

const loggingPlugin: MelonyPlugin = (builder) => {
  builder.on("*", async function* (event) {
    console.log(`[Plugin] Event: ${event.type}`);
  });
};

const agent = melony()
  .use(loggingPlugin)
  .on("user:text", async function* () {
    yield { type: "assistant:text", data: { content: "Hello!" } };
  });

TypeScript Benefits

  • Full type inference through the entire chain
  • IntelliSense for all methods and parameters
  • Generic propagation maintains type safety
  • Minimalist core with zero required dependencies

CLI

Melony comes with a built-in interactive CLI to chat with your agents.

npx melony chat --url http://localhost:4001/api/chat

You can also run it without arguments (defaults to chat):

npx melony

Studio (Recommended)

A local UI for interacting with and debugging your agents.

npx @melony/studio

For more options:

npx @melony/studio --port 4000 --url http://localhost:4001

Core Concepts

  • Event: The universal unit of streaming ({ type, data, meta }).
  • Event Handlers: Reactive functions that listen to and emit events.

License

MIT