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

pico-engine

v1.10.2

Published

Node.js runtime for picos: persistent actors with their own identity, state, and channels that communicate by events and queries. Behavior is written in KRL. Includes an MCP server so AI coding assistants can inspect and drive a running engine.

Readme

pico-engine

Node version

The Node.js runtime for picos (persistent compute objects): actors with their own identity, state, and channels that communicate by events and queries. Pico behavior is written in KRL, which the engine compiles to JavaScript. Documentation: https://docs.picolabs.io/

Quick start

npm install -g pico-engine
pico-engine

Open http://localhost:3000 — a root pico and UI channel are created on first run. Operator settings (port, data dir, policy ceiling) live in ~/.config/pico-engine/config.json; copy config.example.json. See the engine guide.

AI coding assistants: pico-engine mcp --stdio runs an MCP server against the same engine (status, picos, channels, events, queries, KRL validation, and the Try It! demos: list_try_it_demos, run_try_it_demo, try_it_status). It also serves the cookbook and Developing with Picos docs as pico://docs/... resources. Machine-readable docs: llms.txt and llms-full.txt. Repo conventions for agents: CLAUDE.md.

Getting Started

Installing

You'll need node.js LTS or Current (we recommend LTS).

  • Windows - use the installer at nodejs.org
  • Mac - use the installer at nodejs.org or use n bash script (n makes it easy to switch between node versions)
  • Linux - we recommend the n bash script which will allow you to easily install and switch between node versions.

Once you have node installed, use npm to install the pico-engine;

$ npm install -g pico-engine

Now your system has a new command called pico-engine.

To start the engine simply run this command

$ pico-engine

Visit the url http://localhost:3000 in a browser to use the developer UI (described below).

Troubleshooting

If install fails and you see gyp ERR! ... in the output:

pico-engine uses leveldb to store data. It's a C++ library which is prebuilt for most systems. However, if the prebuilt binary is not available for your combination of operating system and node.js version, npm will compile it for you using node-gyp. However, node-gyp assumes your system will have python 2 and a c++ compiler available.

Windows

Open command prompt as Administrator then run npm install --global --production windows-build-tools That will configure python and c++ compiler for npm.

We have had reports that the pico-engine command stops working with earlier versions of node.js, so update to the latest version.

Mac / Linux

Be sure you have python 2.7 installed. If python 3 is the system default, all you need to do is configure npm to use python 2.7 like so npm config set python /path/to/executable/python2.7

To setup C++

# Mac
xcode-select --install
# Ubuntu
sudo apt-get install build-essential
# AWS Linux
sudo yum groupinstall "Development Tools"

For more help, see node-gyp.

Folder problems

When you run the npm install command, if you are in a folder which contains a folder named pico-engine, the command can fail in various ways. Otherwise it doesn't matter which folder you are in, since you are doing a global install.

If these steps don't help

Open an issue and tag @farskipper. Please include your operating system, node.js version (node -v), and a copy of the error output.

Bootstrap

The first time you run the system it will create a root Pico with three rulesets installed.

There are three rulesets used by all Picos:

  • io.picolabs.wrangler is used by each Pico to keep track of itself and its children
  • io.picolabs.pico-engine-ui is used by each Pico to keep track of its rectangle in the developer UI
  • io.picolabs.subscription is used by each Pico to keep track of its subscriptions to other picos

Using the developer UI

With the rulesets installed, you can drag the rectangle representing your Pico and drop it wherever you want it. In its "About" tab (click on it to reveal the tabs) you can change its display name and color.

Also in the "About" tab, you can add and delete child Picos.

In the "Rulesets" tab you can see the rulesets installed in your Pico. By clicking on a ruleset id, you will see the location of its source code.

To make your own ruleset, use an editor to write its KRL code. Enter the URL of that file in the "Rulesets" tab and click on the "Install" button.

Updating/downgrading

Heads up! Especially when downgrading there may be a risk of data loss. It's recommended you backup your pico-engine home folder first. By default the folder is located ~/.pico-engine/ it contains your database.

# to view your current version
$ pico-engine --version

# to view what npm has installed globally, including current version
$ npm ls -g --depth 0 pico-engine

# to view available versions
$ npm view pico-engine versions

# to install a specific version i.e. `0.41.0`
$ npm install -g [email protected]

CLI

Configuration

The server is configured via some environment variables.

  • PORT - The port the http server should listen on. By default it's 3000
  • PICO_ENGINE_HOME - Where the database and other files should be stored. By default it's ~/.pico-engine/
  • PICO_ENGINE_BASE_URL - The public url prefix to reach this engine. By default it's "http://localhost:3000"
  • PICO_ENGINE_ALLOW_SELF_SIGNUP - Set to "true" or "1" to allow open registration after bootstrap (default: off; bootstrap and invite still work)
  • PICO_ENGINE_ALLOW_LOCALHOST_C - "1" or "true" lets a direct loopback connection call /c/* without a passkey (default: off). Proxy headers are never treated as local. The dev MCP sends X-Pico-Internal from $PICO_ENGINE_HOME/internal-token. Full registry: repo MEMORY.md § Engine environment variables.
  • PICO_ENGINE_LOG_FILE - Log file path. Set to stdout, -, or 0 for stdout only (recommended on Fargate + EFS; use CloudWatch for retention). Default: $PICO_ENGINE_HOME/pico-engine.log.
  • PICO_ENGINE_LOG_MIRROR - When stdout-only: true/1 (default) mirrors structured JSON to $PICO_ENGINE_HOME/pico-engine.log so ctx:logs and the Developer UI Logging tab work; set false/0 to skip the mirror file (e.g. avoid EFS log churn). Config: logMirror in config.json (see config.example.json).
  • PICO_ENGINE_SHOW_TRYIT_MENU - Where the Developer UI shows the Try It! tab: off, root_only (default), or all (config: show_tryit_menu).
  • PICO_ENGINE_DEMOS_DIR - A directory to serve as demos/ instead of the copy shipped with the engine, such as the demos/ folder of a pico-engine checkout you're editing.

The PORT is the only value used in setting up the engine’s nodejs http server. We only specify the port so it listens listens to all traffic on that port, it will not filter by host.

For example, say you want to have your engine running with SSL on a custom domain i.e. https://example.com Starting the engine like this PICO_ENGINE_BASE_URL=https://example.com pico-engine is not enough. You will need to use a reverse proxy server like nginx to handle the SSL termination, and then forward the traffic to your private port that is running the engine.

Containers

The public image is public.ecr.aws/f0m0d1a1/pico-engine. latest is the current release. The image is Linux ARM64.

The engine stores mesh state in LevelDB under PICO_ENGINE_HOME:

| Path | Purpose | |------|---------| | db/ | Main mesh state (picos, channels, auth, identity, …) | | rulesets-db/ | Cached flushed ruleset metadata (rebuildable from URLs) | | rulesets/ | Compiled ruleset JS | | pico-engine.log | Rotating log file |

On startup the engine opens both LevelDB directories. If a previous process exited uncleanly (e.g. container SIGKILL), startup removes a stale LOCK file and may run LevelDB repair before failing.

The CLI handles SIGTERM and SIGINT by closing the HTTP server and both databases cleanly.

Docker Compose (local or any host):

services:
  pico-engine:
    image: public.ecr.aws/f0m0d1a1/pico-engine:latest
    ports:
      - "3001:3000"
    environment:
      PICO_ENGINE_HOME: /var/pico-image
      PICO_ENGINE_BASE_URL: http://localhost:3001
    volumes:
      - pico-engine-data:/var/pico-image

volumes:
  pico-engine-data:

Use a named volume or bind mount for PICO_ENGINE_HOME. Do not run two containers against the same volume.

Running on AWS ECS / Fargate

Fargate has no persistent disk of its own. For a mesh that survives redeploys and image updates, mount Amazon EFS at /var/pico-image and set PICO_ENGINE_HOME=/var/pico-image.

EFS + LevelDB is a common deployment pattern. LevelDB expects a single writer; it is not safe for two tasks to share one database directory. With one Fargate task and graceful shutdown, EFS persistence works well in practice.

Do not use Fargate managed EBS for durable mesh storage on a service: those volumes are deleted when the task stops, so each deploy would start with an empty mesh unless you build a snapshot workflow.

Task definition (essentials):

| Setting | Value | |---------|--------| | Container port | 3000 | | PICO_ENGINE_HOME | /var/pico-image | | PICO_ENGINE_BASE_URL | Public HTTPS origin users hit (e.g. https://picos.example.com) — required for passkeys and did:webvh | | PICO_ENGINE_LOG_FILE | stdout — log to CloudWatch | | PICO_ENGINE_LOG_MIRROR | 0 — do not mirror to pico-engine.log on EFS when using stdout-only; or set logMirror: false in config | | EFS mount | containerPath: /var/pico-image | | Container stopTimeout | 120 (seconds) |

PICO_ENGINE_BASE_URL must match the URL in the browser (scheme, host, no trailing slash). Put TLS at Cloudflare, an ALB, or another reverse proxy in front of the task.

Service deployment:

| Setting | Recommended | Why | |---------|-------------|-----| | desiredCount | 1 | One writer per EFS mount | | minimumHealthyPercent | 0 | Stop old task before starting new one | | maximumPercent | 100 | Avoid two tasks on the same volume during deploy | | healthCheckGracePeriodSeconds | 60–120 | Allow startup before health checks fail |

TLS / public URL: Terminate HTTPS in front of the container (ALB, Cloudflare Tunnel, nginx, etc.). The engine listens on HTTP port 3000 inside the task.

If the engine fails to start with LevelDB errors after an unclean shutdown:

  1. Stop the service (ensure no task is using the volume).
  2. Remove only the database directories on the EFS mount: db/ and rulesets-db/.
  3. Start the service again and register a new passkey (fresh mesh).

That wipes mesh state but preserves the volume mount and deployment layout. Export/backup of mesh state is a separate operational concern (see repo design docs on pico move/export).

Checklist for operators:

  • [ ] EFS mounted at /var/pico-image
  • [ ] PICO_ENGINE_BASE_URL set to the public HTTPS URL
  • [ ] Single task per EFS volume
  • [ ] stopTimeout ≥ 60s; deploy stops old task before starting new one
  • [ ] Image includes graceful shutdown (1.6.x+)

Authentication

The developer UI uses passkeys (WebAuthn). On first visit you register a passkey, which creates your account and root pico. Sign in again with the same passkey; add more passkeys or invite others from Settings (gear icon).

When self-signup is disabled, Settings → Invite someone can include an optional bootstrap ruleset URL (file:// or https://). The engine validates the URL when the invite is created; when the invitee registers, that ruleset is installed on their new root after the base OS rulesets (e.g. a Manifold bootstrap KRL). The invite label pre-fills the invitee's mesh name (editable before registering). WebAuthn user.name is set to the mesh name so password managers (e.g. 1Password) show it alongside the site hostname.

  • /c/* — internal/UI API. Requires a passkey session cookie, or the dev MCP's X-Pico-Internal token ($PICO_ENGINE_HOME/internal-token, rewritten each startup). A direct loopback bypass exists only when PICO_ENGINE_ALLOW_LOCALHOST_C=1.
  • /auth/* — registration, login, session management.

OAuth

OAuth protects external access to the mesh on /sky/*. The UI and in-engine loops continue to use passkey sessions on /c/*.

Two grant types can coexist in the same mesh:

| Grant | Use case | Client ID | Scope | |-------|----------|-----------|-------| | Client Credentials | Inbound webhooks (Stripe, GitHub, …) | Channel ECI | Single channel only | | Authorization Code + PKCE | Apps like Home Assistant | app_… | Whole mesh (root + descendants) |

An MCP client discovers this server without a pre-registered app. GET /.well-known/oauth-authorization-server describes the authorization server. GET /.well-known/oauth-protected-resource/mcp/{eci} describes that channel's MCP URL. /mcp/{eci} answers a missing bearer token with 401 and WWW-Authenticate: Bearer resource_metadata="…".

A client can use an https URL as its client_id. The engine fetches that URL as a Client ID Metadata Document. The document's client_id must equal the URL, and its redirect_uris must include the request's redirect_uri. The approval screen shows the client's name, logo, page, and host, plus the mesh and the scopes requested. These clients are public: S256 PKCE and no client secret. Pre-registered apps still work.

Mesh lock

Install the optional ruleset io.picolabs.oauth on the root pico to require a Bearer token on most /sky/* requests for that mesh. Without it, open channels work as before (channel policy only); channels tagged oauth-webhook always require Bearer.

From the Rulesets tab, install io.picolabs.oauth (KRL source: packages/pico-engine/krl/io.picolabs.oauth.krl). Removing the ruleset unlocks the mesh again.

Ruleset queries (install io.picolabs.oauth on the root): meshEnabled(), meshRequiresOAuth(eci), channelStatus(eci), createChannelSecret(eci), … — see krl/io.picolabs.oauth.krl.

Bearer evaluation order (engine skyRequiresBearer):

| Condition | /sky/* Bearer required? | |-----------|---------------------------| | Channel tags didcomm + ingress | No (DIDComm ingress) | | Channel tag oauth-webhook | Yes (Client Credentials) | | Channel tag mesh-oauth-exempt | No (opt out of mesh lock) | | Root has io.picolabs.oauth | Yes (mesh lock) | | Otherwise | No |

Use mesh-oauth-exempt on inbound webhook channels that cannot send Authorization (e.g. LoRa/Helium POST to /sky/event/...) while mesh OAuth stays enabled for integrators (Home Assistant ACG). Tight event policy on those channels still applies. If a channel has both oauth-webhook and mesh-oauth-exempt, oauth-webhook wins (Bearer required).

When mesh OAuth is enabled, the Channels → New Channel form offers a one-click mesh-oauth-exempt tag. Existing channels: add the tag under Edit channel → Tags.

Webhook credentials (Client Credentials)

For channels tagged oauth-webhook at creation time:

  1. Open the channel in the Channels tab.
  2. Create credentials — client_id is the channel ECI; copy the client_secret (shown once).
  3. Mint a test token in the UI, or call POST /oauth/token:
POST /oauth/token
Content-Type: application/json

{
  "grant_type": "client_credentials",
  "client_id": "<channel-eci>",
  "client_secret": "<secret>"
}

The returned oat_… access token works only on /sky/* URLs for that ECI.

Family, subscription, and system channels are not eligible.

OAuth apps (Authorization Code)

For integrators that need access across the mesh (e.g. Home Assistant):

  1. Install io.picolabs.oauth on the root pico (mesh lock).
  2. Settings → OAuth apps — register an app (name, redirect URIs, public vs confidential client). The client ID (app_…) is not secret; a confidential client’s secret is shown once.
  3. The app sends the user to authorize; after passkey consent, the app exchanges the code for tokens.

Authorize (browser; user must be signed in):

GET /oauth/authorize?client_id=app_…&redirect_uri=…&response_type=code&code_challenge=…&code_challenge_method=S256&scope=mesh

Unauthenticated users are redirected to sign in and then returned to authorize (/?oauth_return=…).

Token exchange (must be POST, not a browser GET with query params):

POST /oauth/token
Content-Type: application/json

{
  "grant_type": "authorization_code",
  "code": "oac_…",
  "redirect_uri": "…",
  "client_id": "app_…",
  "code_verifier": "…"
}

PKCE is S256 only: code_challenge is the base64url SHA-256 of code_verifier. Send the same resource on the authorize request and the token request ({base}/sky for Sky, {base}/mcp/{eci} for that channel's MCP URL, or {base}/mcp/mesh/{eci} for the whole-mesh endpoint). A token is accepted only at the resource it names. Tokens issued with no resource still work on /sky/*. mesh:read is required for queries and mesh:act for events.

Refresh:

POST /oauth/token
Content-Type: application/json

{
  "grant_type": "refresh_token",
  "refresh_token": "ort_…",
  "client_id": "app_…"
}

Each refresh returns a new access token and a new refresh token. The previous refresh token no longer works. Sending it again revokes the replacement as well. A public client (no secret, including a Client ID Metadata Document) gets an access token that lasts one hour. A confidential app's access token lasts 24 hours. The refresh token lasts 90 days, and a successful refresh starts that clock again. Send the same resource the grant was issued with.

Use the access token on any channel ECI in the mesh:

GET /sky/query/<eci>/io.picolabs.wrangler/name
Authorization: Bearer oat_…

Token prefixes

| Prefix | Meaning | |--------|---------| | oac_ | Authorization code (single-use, ~10 min) — exchange at /oauth/token, not a Bearer token | | oat_ | Access token — use on /sky/* | | ort_ | Refresh token — use at /oauth/token only |

OAuth HTTP endpoints

| Method | Path | Auth | Purpose | |--------|------|------|---------| | POST | /oauth/token | Public | Client credentials, authorization code, refresh token | | GET | /oauth/token | Public | Dev-friendly alias (query params); prefer POST | | GET | /oauth/authorize | Passkey session | Authorization code + PKCE; consent page | | POST | /oauth/approve | Passkey session | Consent form handler | | GET/POST/DELETE | /oauth/apps | Passkey session | Register/list/revoke OAuth apps | | GET/POST/DELETE | /oauth/channels/:eci/* | Passkey session | Webhook credential management |

Building the UI

Repo root npm run build includes the UI bundle (via lerna run build), copied into packages/pico-engine/public/. Restart the engine and hard-refresh the browser after a build.

For UI development, run the engine and npm run dev in packages/pico-engine-ui in separate terminals.

OAuth tests

cd packages/pico-engine
npm run test:oauth    # webhook Client Credentials
npm run test:acg      # authorization code + refresh
npm run test:http     # /c/* vs /sky/* surface + mesh lock
npm run test:auth     # passkeys

Tests use isolated temp homes and ephemeral ports; they do not require stopping a running engine.

Layer 2 identity and relationships (1.6)

Every pico has a portable did:webvh identity. DID-based relationships (Layer 2) use layer2: true and a target_did (did:webvh) instead of the legacy wellKnown_Tx ECI handshake. After intro, remote traffic uses did:peer DIDs and SKY over DIDComm when picos are on different meshes or engines. Prefer wrangler:relationship and use module io.picolabs.subscription alias relationship in new rulesets; legacy subscription event names remain supported.

  • Same engine: intra-mesh queries/events stay local when roots share a mesh.
  • Cross-engine: set a peer-reachable PICO_ENGINE_BASE_URL on each engine (for local demos, two processes on localhost:3001 and :3002 — see below).
  • Developer UI: Relationships tab (DID-based create, inbound approval, established relationships with Tx_did / Rx_did). A pico cannot target itself (target_did / wellKnown_Tx checks).
  • Legacy ECI relationships are unchanged.

Deprecated: io.picolabs.did-o and dido:prepareQuery — use wrangler:picoQuery and event:send({ did: … }).

Full guide: Layer 2 relationships · Release notes: 1.6 · CHANGELOG.md (1.6.4 mesh-oauth-exempt + KRL directory UI; 1.6.3 fixes)

Dependency: pico-framework is packages/pico-framework in this repo and is versioned with the engine. krl-stdlib, pico-engine-core, and pico-engine depend on it.

Layer 2 tests

cd packages/pico-engine
npm run test:epic9          # release regression matrix
npm run test:cross-engine   # two engines, intro + query + event
npm run test:layer2-wrangler
npm run test:layer2-policy

Cross-engine demo (two processes on one machine)

Use separate data directories and ports so each engine is an independent mesh. PICO_ENGINE_BASE_URL defaults to http://localhost:$PORT, which works for passkeys and for peer DID fetch (same as npm run test:cross-engine).

# terminal 1
PICO_ENGINE_HOME=/tmp/pico-engine-a PORT=3001 npm start

# terminal 2 (from repo root)
PICO_ENGINE_HOME=/tmp/pico-engine-b PORT=3002 npm start

Open http://localhost:3001 and http://localhost:3002 — register on both, then form a Layer 2 relationship A→B. See Layer 2 relationships. Test/demo homes live under /tmp (not ~/.pico-engine).

Contributing

See the repository root readme

Changelog

To view details about versions: CHANGELOG.md

License

MIT