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

@mew-protocol/agent

v0.4.6

Published

TypeScript agent for MEW Protocol

Readme

MEW Protocol TypeScript Agent

A TypeScript implementation of a MEW Protocol agent that extends MEWParticipant from the SDK.

Features

  • Extends MEWParticipant class for full protocol support
  • ReAct (Reasoning + Acting) loop implementation
  • Transparent thinking/reasoning messages
  • Built-in tool support (time, echo, calculator)
  • MCP request/response handling
  • Proposal fulfillment capabilities
  • Configuration via YAML/JSON files
  • Environment variable support

Installation

cd sdk/typescript-sdk/agent
npm install
npm run build

Usage

Basic Usage

# Run with defaults
npm start

# Or use the binary directly
node dist/index.js

Command Line Options

node dist/index.js [options]

Options:
  -g, --gateway <url>     Gateway WebSocket URL (default: ws://localhost:8080)
  -s, --space <name>      Space name to join (default: playground)
  -t, --token <token>     Authentication token (default: agent-token)
  -i, --id <id>          Participant ID (default: typescript-agent)
  -c, --config <file>    Configuration file (YAML or JSON)
  -d, --debug            Enable debug logging
  -h, --help            Show help message

Configuration File

Create a configuration file based on config.example.yaml:

participant_id: my-assistant
name: My Assistant

gateway: ws://localhost:8080
space: dev
token: my-token

systemPrompt: |
  You are a helpful assistant that can...

thinkingEnabled: true
autoRespond: true
maxIterations: 5
logLevel: info

Then run:

node dist/index.js --config my-config.yaml

Environment Variables

export MEW_GATEWAY=ws://localhost:8080
export MEW_SPACE=production
export MEW_TOKEN=secret-token
export MEW_PARTICIPANT_ID=prod-agent

npm start

Architecture

The agent is built on top of the MEW Protocol SDK:

import { MEWParticipant } from '@mew-protocol/participant';

export class MEWAgent extends MEWParticipant {
  // Custom agent logic
}

Key Components

  1. MEWAgent Class: Extends MEWParticipant with agent-specific behavior
  2. ReAct Loop: Implements thinking and acting cycles
  3. Tool Registry: Manages available tools
  4. Message Handlers: Process different message types
  5. Reasoning Support: Transparent thinking messages

Message Flow

  1. Agent receives message (chat, MCP request, proposal)
  2. Starts reasoning sequence (if enabled)
  3. Runs ReAct loop to determine response
  4. Executes actions (tools, fulfillments)
  5. Sends response back

Development

Building

npm run build       # Build once
npm run dev        # Watch mode

Adding Custom Tools

const customTool: Tool = {
  name: 'my_tool',
  description: 'Does something useful',
  inputSchema: {
    type: 'object',
    properties: {
      param: { type: 'string' }
    }
  },
  handler: async (input) => {
    // Tool implementation
    return {
      content: [{
        type: 'text',
        text: `Result: ${input.param}`
      }]
    };
  }
};

agent.addTool(customTool);

Extending the Agent

import { MEWAgent } from './MEWAgent';

class MyCustomAgent extends MEWAgent {
  protected async think(input: string, previousThoughts: ThoughtStep[]): Promise<ThoughtStep> {
    // Custom thinking logic
    // Could integrate with LLMs here
  }
  
  protected async act(action: string, input: any): Promise<string> {
    // Custom action execution
  }
}

Example Sessions

Basic Chat

User: Hello agent!
Agent: [thinking] Understanding greeting...
Agent: Hello! I am an AI assistant ready to help. What can I do for you?

Tool Execution

User: What time is it?
Agent: [thinking] User wants to know the time...
Agent: [executes get_time tool]
Agent: The current time is 2025-09-11T10:30:00Z

Proposal Handling

Untrusted Agent: [proposes] Write to important.txt
TypeScript Agent: [evaluates safety]
TypeScript Agent: [fulfills if safe]

Integration with LLMs

The agent is designed to integrate with LLMs. Override the think() method:

protected async think(input: string, previousThoughts: ThoughtStep[]): Promise<ThoughtStep> {
  const response = await callLLM({
    model: this.config.model,
    messages: [
      { role: 'system', content: this.systemPrompt },
      { role: 'user', content: input }
    ]
  });
  
  return parseThought(response);
}

License

MIT