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

usertrust-acs-adapter

v3.4.0

Published

ACS/AGT composite-evaluator adapter: external policy decides, the usertrust ledger reserves

Readme

usertrust-acs-adapter

ACS/AGT composite-evaluator adapter for the usertrust governance kernel. It occupies the SpendGuard composite slot documented by Microsoft's Agent Governance Toolkit: a stateless policy layer decides, and the usertrust ledger provides the stateful two-phase reservation (PENDING hold → settle or void) behind it.

The composite contract

  1. The external policy decides FIRST (allow / warn / deny / escalate / transform).
  2. On allow/warn, the usertrust ledger atomically reserves (a PENDING hold).
  3. A denied action never consumes a reservation.

If the ledger cannot reserve, the allow is converted to deny with an ACS-vocabulary reason (budget_cost_usd_exceeded, or usertrust:policy_denied:<reason>). A policy that returns malformed output fails closed: deny with runtime_error:policy_output_invalid. Each CompositeResult is one-shot — a second settle() returns null and a second (or post-settle) abort() is a no-op.

Usage

import { CompositeEvaluator, createMockGovernor } from "usertrust-acs-adapter";

const { governor } = createMockGovernor({ budget: 1000 }); // or createGovernor() from usertrust/headless
const evaluator = new CompositeEvaluator({
	policy: (action, { inputIdentity, budgets }) =>
		action.kind === "exfiltrate" ? { decision: "deny", reason: "blocked" } : { decision: "allow" },
	governor,
});

const result = await evaluator.evaluate({
	kind: "tool_call",
	model: "claude-sonnet-4-6",
	estimatedInputTokens: 200,
	maxOutputTokens: 500,
});
if (result.verdict.decision === "allow") {
	// ... run the action ...
	await evaluator.settle(result, { inputTokens: 210, outputTokens: 480 });
	// or, for a call that hit the model's cache:
	// await evaluator.settle(result, {
	//   inputTokens: 40, outputTokens: 480, cacheReadTokens: 170, cacheWriteTokens: 0,
	// });
} // denied? nothing to clean up — no reservation was made

runDemo() produces an infrastructure-free transcript of all three contract lines.

evaluate_only mode

With mode: "evaluate_only" the adapter is a pure shadow evaluator: the policy verdict is preserved exactly as decided (a deny stays a deny in result.verdict), but nothing is enforced — result.enforced is false, the ledger is never touched, no reservation is made, and settle()/abort() are no-ops returning null. Use it to observe what a policy would do before turning enforcement on. (Note: the usertrust-server layer defines its own, different evaluate_only semantics — see that package's README.)

ACS compatibility

The verdict set, the reserved runtime_error:* reason namespace, and the envelope.budgets counters (tool_call_count, token_count, elapsed_seconds, cost_usd) follow the Agent Control Specification so the adapter can sit behind an ACS-style policy layer unchanged. usertrust meters in usertokens; cost_usd carries the usertoken cost unless the deployment configures a conversion. Action identity (canonicalJson/actionIdentity) is the adapter's own namespace — unrelated to core's audit-chain canonicalization.

token_count sums all four disjoint tiers settle() accepts — fresh input, output, cache-read, cache-write — not just input+output, so a cache-heavy session no longer under-reports against the ACS-spec envelope. The ACS envelope itself stays fixed to its four counters; the per-tier breakdown (CompositeEvaluator.tokenCounts()) lives outside it as an additive, adapter-specific accessor rather than widening that contract.

Patterns and schemas adapted from the Microsoft Agent Governance Toolkit (MIT License) — see the repository NOTICE file. No Microsoft source code is included.