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

@looprun-ai/server

v0.20.0

Published

looprun model server: expose governed LoopRunAgents behind an OpenAI-compatible /v1/chat/completions endpoint, so any harness that speaks the OpenAI protocol can call a governed agent as if it were a model. The full governed turn (guards, tools, redrive)

Readme

@looprun-ai/server

Expose governed LoopRun agents behind an OpenAI-compatible endpoint — the "agent-as-model" pattern. Any harness that can point a custom provider at a base_url (personal-agent frameworks, Open WebUI, IDE assistants, plain OpenAI SDKs) calls a governed agent as if it were a model: the full governed turn (guards → tools → redrive) runs inside each /v1/chat/completions request and returns one final assistant message.

New to looprun? Start with the tutorial: 01 · Concepts — six chapters, one running example; chapter 06 serves this agent over HTTP.

import { createModelServer } from '@looprun-ai/server';
import { LoopRunAgent } from '@looprun-ai/mastra';

const agent = new LoopRunAgent({ spec, world: worldFactory, toolDefs, model });
const server = await createModelServer({ agents: { 'inbox-triage': agent }, port: 8099 });
console.log(server.url); // http://127.0.0.1:8099/v1

Point the harness at it:

# e.g. a harness config.yaml
model:
  provider: custom
  base_url: "http://127.0.0.1:8099/v1"   # model field selects the agent: "inbox-triage"
  context_length: 128000

The mapping law (what the facade does with the incoming request)

The server implements the protocol as a facade — the harness believes it is talking to a model, so parts of the request that would fight the spec are deliberately not honored:

| Incoming | Treatment | Why | |---|---|---| | model | routes to the registered agent | one server, N agents as N "models" | | last user message | the governed turn's input | the agent's own session is the canonical memory | | earlier history | ignored (transport-only) | harnesses compress/rewrite it; replay would desync the governed state | | system message | discarded | the AgentSpec renders its own assembled prompt (byte-stable, cache-friendly) | | tools, tool_choice | ignored | the spec owns the tool surface; guards govern every call | | temperature etc. | ignored | spec.controls.sampling governs | | stream: true | honored (see below) | |

Sessions

The protocol is stateless; the agent is stateful. Session id resolution, first hit wins:

  1. x-looprun-session header (explicit — always safe; OpenAI SDKs support default_headers),
  2. the OpenAI-standard user field,
  3. fingerprint fallback: hash of model + the first user message — stable for a conversation unless the harness compresses that message away (mitigated by the high context_length reported by /v1/models). A changed fingerprint starts a fresh session: degraded, never unsafe.

Concurrent requests on the same session serialize; different sessions run concurrently. Optional sessionTtlMs evicts idle sessions via agent.endSession().

Streaming

stream: true still runs the governed turn to completion (streaming cannot be governed at the reply level), then emits a valid SSE stream: an immediate role delta, : keepalive comments while the turn runs, one content delta with the full governed text, a finish chunk, [DONE].

Observability

Every response carries a non-standard looprun field (sessionId, turnIndex, corrections, exhausted, violations) — OpenAI SDKs ignore it; integration harnesses can assert on it. onTurn fires server-side after every governed turn with the same metadata.

API

  • createModelServer(config) → { url, port, handler, close() } — node:http server, ephemeral port by default. The returned handler is the bare fetch-style (req: Request) => Promise<Response>, so you can embed the governed endpoint in any web server without taking the node:http listener: build one with port: 0, use .handler, and close() when done.
  • config: agents (model id → LoopRunAgent), port, hostname, contextLength, apiKey (optional bearer check), resolveSession, sessionTtlMs, onTurn.