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

watch-agent

v1.0.5

Published

Make your agents on command line.

Readme

Watch Agent using command line

A command line wrapper for monitoring, iterations and long processes

So tell me

  • Have you ever thought of running a iterative process on your command line ?
  • Has it ever been simple to develop ?
  • Have you ever not procrastinated to develop such a script ?

Watch Agent is here to rescue. It makes developing any iterative process as easy as just fetching data and showing it on command line. Just go ahead and install watch-agent start creating your own agents.

Installation

    npm i -g watch-agent

Usage:

1. Start an agent

    wa start <agent> [args...]

agent - name of the agent

args - agruments to be passed for agent to start an instance

Options:

  • -d, --delay [optional] Delay in seconds between each fetch call. 60 seconds delay if not specified.
  • -t, --times [optional] Number of times to execute. Infinite times if not specified.

2. Stop an agent

    wa stop <agent> <pid>

agent - name of the agent

pid - process id of the agent to be stopped

3. Show running agent details

    wa show <agent> [args...]

agent - name of the agent

args - arguments to be passed for agent to show data

Making your own agents

Step 1: Create a directory and add that directory in env variable WATCH_AGENT_REPO. Recommended is to add this variable to .bash_profile for linux and mac systems. And system path for windows application

export WATCH_AGENT_REPO=~/watch-agent-repo

Step 2: Create sub directories inside that folder with the name of the agent prefixed with wa-.

Sample directory structure

.
├── common                  --> Common code required for all the agents
│   ├── http-client.js
│   └── prompt.js
├── node_modules            --> Node imports
│   └── **
├── package-lock.json
├── package.json            --> Node package.json
├── wa-agent1               --> Agent directory
│   └── index.js            --> index.js file which `watch-agent` will
├── wa-agent2                   invoke with `wa start agent1`
│   └── index.js
└── wa-agent3
    └── index.js

Step 3: Create an index.js with the structure as given below.

module.exports = {
    init: async (handler, args) => {
        /**
         * [Optional]
         * This method will be called only for the first time when we start an agent.
         * It can we used to prompt for additional inputs or cancel agent from starting, if already existing.
         * It should return args which will be further passed on to fetch method of each iteration.
         * If false is returned agent will not be started.
         */
        return args;
    },
    fetch: (handler, args) => {
        /** 
         * [Mandatory]
         * This method will be called for each iteration
         * You can return either a promise or an object.
         */
        return data;
    },
    infer: (handler, data) => {
        /** 
         * [Optional]
         * This method is used to perform additional operations based on data from fetch
         */
    },
    display: (handler, args) => {
        /**
         * [Mandatory]
         * You can use the handler to get all records and use console.log to print when `wa show <agent>` command is called.
        */
    }
};

Once this is done. You can start using watch-agent using the commmands specified.

Handler

We have below given method that can be called using the handler object.

  1. handler.getAllRecords() - Will give you list of latest records of all instances of your agent in an array.
  2. handler.getPreviousRecord() - Will get you only the previous record for the current agent instance.

Record Object

Sample record object

{
    "args" : ["arg1","arg2"],
    "iteration" : "4",
    "status" : "SUCCESS",
    "pid" : 2104,
    "data" : ...
}
  1. args - arguments passed in start command.
  2. iteration - index of iteration currently in progress (starts from 1)
  3. status - status of the previous execution
  4. pid - os process id
  5. data - data returned from fetch operation