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

smallville

v1.0.3

Published

Create custom generative agent simulations

Readme

Smallville is a javascript library to create custom generative agent simulations in web browsers. Generative Agents use LLM's to create realistic NPC charcters and are most useful for research and video games.

Install the necessary files

Start a new javascript project

npm init
npm i smallville

Download the compiled jar from releases

Example

const sim = new Smallville({
        host: "http://localhost:8080", // host of the server
        stateHandler: function(state) {
                //in here you would update the location of the agent using your own pathfinding algorithm
                const currentLocation = state.agents[0].getCurrentLocation()
                const newLocation = state.agents[0].getNextLocation()
                const emoji = state.agents[0].getEmoji()
                const activity = state.agents[0].getCurrentActivity()
                
                const updatedLocations = state.locations;
                
                const conversations = state.conversations;
                
                console.log('[State Change]: The simulation has been updated')
    },
});

Create new location trees

sim.createLocation({
   name: 'Barn',
})

sim.createObject({
   name: 'Hay Pile',
   state: 'Full',
   parent: 'Barn'    
})

Add new agents and initialize their memory stream with starting memories

sim.createAgent({
  name: 'John',
  location: 'Barn',
  memories: [
    "John is a farmer at the Barn",
    "John is a nice and outgoing person"
  ]
})

Increment the time clock. The simulation will get the current time and update the agents state

sim.updateState();

Keep calling sim.updateState whenever you want to update the simulation step

To add new observations to the agent which they will prompt a reaction to use the following method

sim.addObservation({name: "Full Agent Name", observation: "memory description", reactable: true})

Such observations such as encountering another agent or discovering a location should make use of this

For observatonal purposes, you can also ask an agent a question which will use their relevant memories to answer the question

sim.askQuestion("John", "What do you do in your free time")

This will not store the question in the agents memory unless you call sim.addObservation()

Furthermore, locations should be given as a full tree. ex)

location: "Island: Red House: desk"

And the leaf node (in this example desk), should have a state, although it is not necessary. Adding states to leaf locations enables the agents to interact with the world. To get the leaf location and move the agent to the location you can use our utility function getLeafLocation(location) or make your own method.