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

@oxdeai/core

v0.5.0

Published

[![npm version](https://img.shields.io/npm/v/@oxdeai/core.svg)](https://www.npmjs.com/package/@oxdeai/core) [![license](https://img.shields.io/npm/l/@oxdeai/core.svg)](https://github.com/AngeYobo/oxdeai-core/blob/main/packages/core/LICENSE) [![build](http

Downloads

1,253

Readme

@oxdeai/core

Deterministic Economic Containment Engine for Autonomous Systems

npm version license build

@oxdeai/core is a TypeScript library that enforces economic invariants for autonomous agents and programmable services before execution.

It evaluates structured action intents against a deterministic policy state, and emits a signed authorization when allowed.

This is not observability. This is pre-execution containment.


Why

Agentic systems amplify cost and risk via:

  • tool-call chains and retries
  • recursion / planning loops
  • parallel executions (concurrency blowups)
  • consumption-based billing (tokens, APIs, compute)

Most teams rely on dashboards and alerts (post-fact). @oxdeai/core aims to provide hard, deterministic guardrails at the execution boundary.


What this library does (and does not)

Does

  • Deterministic evaluation: given (intent, state, policy_version) ⇒ stable decision
  • Pure evaluation path (evaluatePure) returning nextState
  • Backward-compatible state-committing path (evaluate)
  • Signed authorizations (HMAC) + verification
  • Hash-chained audit log for decisions
  • Composable invariant modules (budget / velocity / replay / recursion / concurrency)

Does NOT

  • move funds, custody keys, or manage wallets
  • replace cloud budgets or billing tools
  • do content moderation or prompt-injection security
  • provide a dashboard (by design)

Core model

@oxdeai/core evaluates:


Agent / Runtime
↓
Structured Intent (what you want to do)
↓
PolicyEngine (@oxdeai/core)  →  ALLOW + Authorization  OR  DENY + Reasons
↓
Execution Layer (APIs / payments / infra provisioning)

Installation

npm install @oxdeai/core

Concepts

Intent

A structured request representing an economic action.

Examples:

  • EXECUTE a paid tool call
  • RELEASE an execution slot after completion

State

A deterministic policy state containing:

  • per-agent budget limits and spend
  • velocity windows
  • replay protection (nonce windows)
  • recursion depth caps
  • concurrency caps and active authorizations

Authorization

If an intent is allowed, the engine emits a signed authorization:

  • bound to intent_hash, policy_version, and state_snapshot_hash
  • includes an expiry (expires_at)
  • verifiable via verifyAuthorization()

Example: Evaluate + Commit (backward-compatible)

evaluate() mutates the passed state by committing nextState.

import { PolicyEngine } from "@oxdeai/core";
import type { State, Intent } from "@oxdeai/core";

const engine = new PolicyEngine({
  policy_version: "v0.2",
  engine_secret: process.env.OXDEAI_ENGINE_SECRET!,
  authorization_ttl_seconds: 60,
});

const state: State = {
  policy_version: "v0.2",
  period_id: "2026-02",
  kill_switch: { global: false, agents: {} },
  allowlists: {},
  budget: { budget_limit: { "agent-1": 10_000n }, spent_in_period: { "agent-1": 0n } },
  max_amount_per_action: { "agent-1": 5_000n },
  velocity: { config: { window_seconds: 60, max_actions: 100 }, counters: {} },

  replay: { window_seconds: 3600, max_nonces_per_agent: 256, nonces: {} },
  recursion: { max_depth: { "agent-1": 2 } },
  concurrency: { max_concurrent: { "agent-1": 2 }, active: {}, active_auths: {} },
};

const intent: Intent = {
  agent_id: "agent-1",
  type: "EXECUTE",
  tool_call: true,
  tool: "openai.responses",
  nonce: 42n,
  amount: 100n,
  timestamp: Math.floor(Date.now() / 1000),
  depth: 0,
};

const result = engine.evaluate(intent, state);

if (result.decision === "DENY") {
  console.error("Blocked:", result.reasons);
  process.exit(1);
}

console.log("Allowed, authorization:", result.authorization.authorization_id);

Example: Pure evaluation (recommended for infra)

evaluatePure() returns nextState without mutating the input state.

const out = engine.evaluatePure(intent, state, { mode: "fail-fast" });

if (out.decision === "DENY") {
  console.error(out.reasons);
} else {
  // persist out.nextState in your store (db/redis/etc)
  // then execute the action using out.authorization
}

Concurrency lifecycle: RELEASE (authorization-bound)

To avoid concurrency deadlocks, RELEASE must reference a real authorization_id that is currently active.

const releaseIntent: Intent = {
  agent_id: "agent-1",
  type: "RELEASE",
  authorization_id: out.authorization.authorization_id,
  nonce: 43n,
  amount: 0n,
  timestamp: Math.floor(Date.now() / 1000),
};

const rel = engine.evaluatePure(releaseIntent, out.nextState);

if (rel.decision === "DENY") {
  console.error("Release denied:", rel.reasons);
} else {
  // persist rel.nextState
}

Built-in modules

  • KillSwitchModule: global or per-agent shutdown
  • AllowlistModule: allowlist action types / assets / targets
  • ReplayModule: nonce window (prevents replay)
  • RecursionDepthModule: max planning / tool-call depth
  • ConcurrencyModule: max in-flight executions + authorization-bound release
  • ToolAmplificationModule: windowed tool/API call caps (prevents tool-call amplification loops)
  • BudgetModule: per-period spend cap + per-action cap
  • VelocityModule: action count rate limit per window

Determinism and auditability

  • Decisions are deterministic for the same (intent, state, policy_version)
  • The engine produces signed authorizations (HMAC)
  • A hash-chained audit log records intent hashes and decisions

Roadmap

Near-term (v0.3)

  • Tool amplification limits (tool-call cap per window)
  • Deterministic replay trace hash (evaluation id)
  • Cleaner audit output as data (optional pure mode: return events instead of mutating engine.audit)

Mid-term

  • Pluggable state adapter interface (Redis / Postgres reference adapters)
  • Simulation tooling (policy stress tests / Monte Carlo)
  • WASM-compatible build target

License

Apache-2.0