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

@cleocode/runtime

v2026.11.23

Published

Long-running process layer for CLEO — agent polling, SSE connections, heartbeat, key rotation

Readme

@cleocode/runtime

Part of CLEO. Start with the root README; run cleo <command> --help for any command.

Runtime layer for CLEO. It has three parts, exported as separate subpaths:

| Subpath | What it is | Status | |---|---|---| | @cleocode/runtime/gateway (+ /gateway/dispatch, /gateway/http, /gateway/rpc, /gateway/mcp) | The transport-agnostic dispatcher behind the CLI. The CLI adapter injects the domain handlers and middleware (packages/cleo/src/dispatch/adapters/cli.ts). /gateway/http is the HTTP gateway with the versioned /v1 REST facade, which cleo daemon serve starts (loopback 127.0.0.1:7777 by default) | Kept (ADR-098). The MCP server under /gateway/mcp is not wired to any command; wiring it as cleo mcp serve or deleting it is an open owner call in ADR-098. | | @cleocode/runtime/daemon | defineSubsystem and SubsystemRegistry: one start → healthProbe → shutdown lifecycle for long-running concerns. cleo web and cleo docs viewer start run as subsystems built with it; the core GC subsystem (createGcSubsystem) implements the same Subsystem contract. Also ships the NDJSON IPC clients for the Rust cleo-supervisor | In use | | @cleocode/runtime (root) | createRuntime(), the agent services (poller, heartbeat, key rotation, SSE) and the sentient subsystem adapter (createSentientSubsystem, bootstrapSentientRegistry) | Frozen for removal (ADR-098). Nothing in the CLI imports the root entry. ADR-098 deletes the services and the sentient subsystem host together with the other npm-breaking parts, in one announced release, after a release has shipped the freeze. The services were built for SignalDock, which is retired; AgentMBX is CLEO's messaging layer (D11176). |

The rest of this README documents the frozen root exports as they ship today.

Install

pnpm add @cleocode/runtime

Public API (root)

import {
  createRuntime,
  type RuntimeConfig,
  type RuntimeHandle,
  AgentPoller,
  HeartbeatService,
  KeyRotationService,
  SseConnectionService,
  createSentientSubsystem,
  bootstrapSentientRegistry,
} from '@cleocode/runtime';

createRuntime(registry, config?)

Resolves an agent credential from the registry (config.agentId, else the active agent), resolves and connects a transport, configures the poller and the ancillary services, and returns a RuntimeHandle. registry is an AgentRegistryAPI (@cleocode/contracts); core's implementation is AgentRegistryAccessor. It throws when no agent credential is found.

import { createRuntime } from '@cleocode/runtime';
import { AgentRegistryAccessor } from '@cleocode/core/internal';

const registry = new AgentRegistryAccessor('/path/to/project');
const handle = await createRuntime(registry, {
  agentId: 'cleo-prime',
  pollIntervalMs: 5000,
  heartbeatIntervalMs: 30000,
  groupConversationIds: ['general', 'announcements'],
});

handle.poller.onMessage(async (msg) => {
  // handle inbound messages
});

// later
handle.stop();

RuntimeConfig

interface RuntimeConfig {
  agentId?: string;              // defaults to the active agent
  pollIntervalMs?: number;       // default: 5000
  groupConversationIds?: string[];
  groupPollLimit?: number;       // default: 15
  heartbeatIntervalMs?: number;  // default: 30000, 0 to disable
  maxKeyAgeMs?: number;          // default: 30 days, 0 to disable
  sseEndpoint?: string;
  createSseTransport?: () => Transport;
  transport?: Transport;         // pre-created, bypasses auto-resolution
}

RuntimeHandle

interface RuntimeHandle {
  poller: AgentPoller;
  heartbeat: HeartbeatService | null;
  keyRotation: KeyRotationService | null;
  sseConnection: SseConnectionService | null;
  transport: Transport;
  agentId: string;
  stop: () => void;
}

heartbeat and keyRotation are null when disabled or when the credential's base URL is a retired SignalDock host (T13169). stop() stops the poller, heartbeat, key rotation and SSE connection, then disconnects the transport.

Services

AgentPoller

The polling loop. Fetches direct messages and group-conversation messages that mention the agent on a configurable interval, deduplicates by message ID across both sources, and dispatches each new message to the handlers registered with onMessage().

HeartbeatService

Sends a periodic online-status heartbeat to the agent's cloud API. Failures are retried silently. A retired SignalDock host is refused before any network I/O. Disabled when heartbeatIntervalMs === 0.

KeyRotationService

Checks the credential's age on an interval and calls the registry's rotateKey() once it is older than maxKeyAgeMs. A failed rotation is retried on the next check. Disabled when maxKeyAgeMs === 0.

SseConnectionService

Optional persistent Server-Sent Events connection for real-time delivery, started only when an SSE endpoint and a createSseTransport factory are both present. When the SSE transport falls back to HTTP polling, the service keeps running.

Sentient subsystem

createSentientSubsystem expresses the sentient daemon lifecycle as one Subsystem for hosts that drive a SubsystemRegistry; bootstrapSentientRegistry(projectRoot, opts?) boots the sentient daemon through a SubsystemRegistry, installing SIGTERM/SIGINT handlers that shut it down. ADR-098 removes this host along with the services.

Transport resolution

When config.transport is not given, createRuntime() uses core's conduit.resolveTransport() (packages/core/src/conduit/factory.ts):

  1. LocalTransport when the project store exists: messages are read and written in the project cleo.db, with no network.
  2. SseTransport when the credential is cloud-backed and has an SSE endpoint.
  3. HttpTransport otherwise. Its connect() refuses a retired SignalDock host.
caller (nothing in the CLI calls it today)
        │
        ▼
@cleocode/runtime  createRuntime()
  AgentPoller · HeartbeatService · KeyRotationService · SseConnectionService
        │
        ▼
Transport (@cleocode/contracts), resolved by core conduit: Local | SSE | HTTP

CANT profile execution

createRuntime() does not execute .cant workflow profiles. CLEO runs deterministic .cant pipelines with cleo cant execute <file> --pipeline <name>; LLM-dependent constructs go through the Pi cant-bridge extension (packages/cleo-os/extensions/cleo-cant-bridge.ts), which retires with the Pi/CleoOS harness (ADR-098, which supersedes ADR-035). CLEO Goal (ADR-097) is the autonomous driver.

Testing

pnpm --filter @cleocode/runtime test

Tests live in src/__tests__/, src/daemon/__tests__/ and src/gateway/**/__tests__/.

Related

License

MIT