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

@spendguard/sdk

v0.5.0

Published

SpendGuard SDK — runtime safety layer client for AI agent frameworks (TypeScript half; mirror of spendguard-sdk on PyPI). v0.1.0 is the first public release; see CHANGELOG.md.

Readme

@spendguard/sdk

npm license publish

Runtime safety-layer client for AI-agent frameworks (TypeScript). Mirror of spendguard-sdk (Python).

@spendguard/sdk is the shared substrate that per-framework adapters (@spendguard/langchain, @spendguard/vercel-ai, @spendguard/openai-agents, @spendguard/inngest-agentkit) build against. It implements the gRPC-over-UDS client for the SpendGuard sidecar, plus the deterministic helpers that produce byte-identical output to the Python SDK and the Rust sidecar — the audit-chain invariants that make idempotency replay and dedup correct across languages.

Install

pnpm add @spendguard/sdk @opentelemetry/api
# or
npm install @spendguard/sdk @opentelemetry/api
# or
bun add @spendguard/sdk @opentelemetry/api

@opentelemetry/api is an optional peer dep — install it only if you plan to pass an otelTracer. Adapters that never enable OTel pay zero extra dependency cost.

Quick start

// reserve -> commitEstimated -> release  (the v0.1.0 happy path)
import {
  SpendGuardClient,
  deriveIdempotencyKey,
  newUuid7,
  USD_MICROS_PER_USD,
} from "@spendguard/sdk";

const client = new SpendGuardClient({
  tenantId: "acme-prod",
  socketPath: "/run/spendguard/sidecar.sock",
  handshake: { protocolVersion: 1, capabilities: {} },
});

await client.handshake();

const decision = await client.reserve({
  trigger: "LLM_CALL_PRE",
  runId: newUuid7(),
  stepId: newUuid7(),
  llmCallId: newUuid7(),
  decisionId: newUuid7(),
  route: "openai:gpt-4o-mini",
  projectedClaims: [
    { scopeId: "team:eng", amountAtomic: "150000", unit: { unit: "usd_micros", denomination: 1 } },
  ],
  idempotencyKey: deriveIdempotencyKey({
    tenantId: "acme-prod",
    sessionId: "sess-1",
    runId: "run-1",
    stepId: "step-1",
    llmCallId: "call-1",
    trigger: "LLM_CALL_PRE",
  }),
});

if (decision.decision === "CONTINUE") {
  // ...call the provider (OpenAI, Anthropic, etc.) here...
  await client.commitEstimated({
    runId: "run-1", stepId: "step-1", llmCallId: "call-1",
    decisionId: decision.decisionId,
    reservationId: decision.reservationIds[0]!,
    estimatedAmountAtomic: String(123 * USD_MICROS_PER_USD / 1_000_000),
    unit: { unit: "usd_micros", denomination: 1 },
    pricing: { pricingVersion: "v2026.05.09-1", pricingHash: new Uint8Array() },
    providerEventId: "openai:chatcmpl-abc",
    outcome: "SUCCESS",
  });
  await client.release({
    runId: "run-1", stepId: "step-1", llmCallId: "call-1",
    decisionId: decision.decisionId,
    reservationId: decision.reservationIds[0]!,
    releaseReason: "COMPLETED",
  });
}

The substrate also exposes requestDecision() as a referential alias for reserve() (client.reserve === client.requestDecision) so call-sites written against the Python SDK transliterate without semantic surprise.

Subpath exports

Tree-shake what you need:

| Subpath | Contents | |---|---| | @spendguard/sdk | Full barrel (everything below). | | @spendguard/sdk/client | SpendGuardClient + request/response types. | | @spendguard/sdk/errors | Typed error hierarchy. | | @spendguard/sdk/ids | newUuid7, deriveIdempotencyKey, deriveUuidFromSignature. | | @spendguard/sdk/pricing | PricingLookup, USD_MICROS_PER_USD. | | @spendguard/sdk/pricing/demo | Embedded DEMO_PRICING snapshot. | | @spendguard/sdk/promptHash | computePromptHash. | | @spendguard/sdk/runPlan | withRunPlan, currentRunPlan (AsyncLocalStorage). | | @spendguard/sdk/otel | Optional OTel span wrapper. | | @spendguard/sdk/retry | Bounded retry helper. | | @spendguard/sdk/cache | In-memory idempotency cache. | | @spendguard/sdk/proto | Generated proto types. |

Cross-language byte-equivalence (P0)

Three functions in this SDK MUST produce byte-identical output to the Python SDK and the Rust sidecar:

  • computePromptHash(text, tenantId) — HMAC-SHA256 lowercase hex.
  • deriveIdempotencyKey({ ... })sg- + 32 hex chars.
  • deriveUuidFromSignature(sig, { scope }) — BLAKE2b-based UUID.

Drift breaks audit-chain rule dedup and the idempotency-replay collapse contract. The corpus that pins this is shipped inside the npm tarball at fixtures/cross-language/v1.json — both this SDK and the Python SDK consume the same file. See sdk/fixtures/cross-language/README.md in the source repo for the runbook.

Compatibility

  • Node 20.10+ is the primary target.
  • Bun 1.1+ and Deno 1.46+ are tested as secondary targets.
  • Browser is NOT supported in v0.1.x — UDS transport is server-only.

Links

License

Apache-2.0. See LICENSE in the repository root.