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

ajnas-runtime

v0.2.1

Published

Policy-gated agent workflow runtime with provenance receipts and human approval checkpoints.

Readme

ajnas-runtime

Policy-gated agent workflow runtime with provenance receipts and human approval checkpoints.

ajnas-runtime is the foundation package for the Ajnas enterprise agent framework. It gives an agent workflow a small, auditable execution kernel:

  • tools are registered through explicit contracts
  • every tool call is evaluated by a policy engine
  • high-risk calls can require a human approval response
  • every run emits chained provenance receipts
  • optional file-backed snapshots make runs resumable/auditable by downstream systems

The package is original Ajnas implementation work. It was shaped by public OSS research, but it does not vendor or copy third-party source code, examples, docs, or branding.

Install

npm install ajnas-runtime

Quick Start

import {
  AgentRuntime,
  FileRunStore,
  InMemoryProvenanceSink,
  ToolRegistry
} from "ajnas-runtime";

const tools = new ToolRegistry().register({
  name: "research.search",
  description: "Search trusted public sources.",
  risk: "low",
  execute: async ({ input }) => ({ summary: `found sources for ${input.query}` })
});

const runtime = new AgentRuntime({
  tools,
  provenance: new InMemoryProvenanceSink(),
  store: new FileRunStore({ directory: ".ajnas-runs" }),
  policy: {
    evaluate: async ({ tool }) => ({
      decision: tool.risk === "critical" ? "require_approval" : "allow",
      reason: "default release-safety policy"
    })
  },
  approver: {
    requestApproval: async ({ bindingDigest }) => ({
      approved: false,
      approverId: "release-owner",
      comment: "external publish waits for explicit release approval",
      bindingDigest
    })
  }
});

await runtime.run({
  name: "research-workflow",
  input: { topic: "agent provenance" },
  steps: [
    {
      id: "search",
      run: (context) =>
        context.callTool("research.search", { query: context.input.topic }, { purpose: "collect sources" })
    }
  ]
});

Core API

  • AgentRuntime: executes ordered workflow steps and owns policy/provenance/store coordination.
  • ToolRegistry: registers named tools with descriptions, risk levels, optional input schemas, and execution handlers.
  • PolicyEngine: decides allow, deny, or require_approval for each tool call.
  • Approver: resolves required approvals with approved, approverId, optional comment and metadata, plus an exact echo of the request's bindingDigest.
  • InMemoryProvenanceSink: captures runtime events for tests, logs, and adapters.
  • FileRunStore: writes run snapshots as JSON files using atomic replacement.

Event Model

Every emitted event includes:

  • runId
  • monotonically increasing sequence
  • type
  • ISO timestamp
  • structured data
  • receipt.eventHash
  • receipt.previousHash
  • receipt.canonicalJson

The hash chain lets downstream systems detect removed or reordered events inside one run trace. ajnas-provenance adds signed evidence bundles and export formats without changing the runtime contract; durable remote ledger storage remains a host concern.

Safety Model

The runtime does not trust prompts or tool descriptions to enforce safety. Tool calls must pass the policy layer first. A policy can:

  • allow low-risk calls
  • deny dangerous calls before execution
  • require approval for high-risk actions such as repository writes, package publishing, email sends, or production deploys

When no policy engine is configured, the runtime denies every tool call. Callers must opt into executable behavior by supplying an explicit policy.

If approval is required but no approver exists, the runtime throws ApprovalRequiredError. If the approver rejects the action, it throws ApprovalRejectedError. An approver response that does not exactly echo the request's bindingDigest is rejected with ApprovalBindingError, preventing a decision for one input or policy context from authorizing another. These paths are recorded in provenance before the workflow fails.

For staged, auditable human review, ajnas-approvals exports createRuntimeApprover. The adapter is structurally assignable to this package's Approver interface and does not introduce a package dependency in either direction. It maps approved and rejected terminal tickets to normal runtime responses and raises a typed RuntimeApprovalPendingError when a host has not resolved the ticket yet.

Local Development

npm install
npm test
npm run typecheck
npm run build
npm run example:basic
npm run pack:dry

Release Status

Version 0.2.1 is the coordinated trusted-publishing patch. Its metadata-only policy tool projection remains the intentional security-motivated API break introduced in 0.2.0.