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

koatty_guard

v1.0.0

Published

AI guardrails for Koatty: masking, prompt-injection detection, human approval, rate limiting and auditing.

Readme

koatty_guard

AI guardrails for Koatty: masking, prompt-injection inspection, human approval, rate limiting and auditing — built on the EXISTING AOP implementation, not on a new decorator stack.

Roadmap: docs/koatty-hardening-and-ai-evolution-plan.md → Phase F, item F-3.

Design constraints (from the roadmap)

  • No new Guard base class and no new decorator stack: the services are plain classes, and a single GuardAspect implements IAspect from koatty_container (the existing @Around / @Before pipeline applies one Around per method, so composing several independent aspects is not a supported assumption).
  • Rule-based inspection only catches known patterns. The primary defences stay the permission scopes and human approval of koatty_mcp (F-1).
  • Everything fails closed: a call that needs approval without a configured backend never executes, and a ticket that times out is rejected.

Use

import { createGuard } from 'koatty_guard';

const guard = createGuard({
  app,                                   // Koatty application (current context)
  rateLimit: 60,                         // calls per caller+tool per window
  windowMs: 60_000,
  approvalTimeoutMs: 5 * 60 * 1000,      // silence == rejection
  requiresApproval: (tool) => tool === 'order.refund',
  inspectsContent: (target) => target === 'llm.ask',
  auditSink: (record) => logger.info('guard-audit', record),
});

// The approval backend also satisfies koatty_mcp's `ApprovalService`:
const host = createMcpHost({ app, approval: guard.approval, audit: guard.audit, redact: (v) => guard.masking.mask(v) });

Wrap a business call with the composed aspect (also what @Around calls):

const result = await guard.aspect.runGuarded('order.refund', [dto], () => orderService.refund(dto));

| Service | Purpose | |---|---| | createMaskingService | Redacts phone / national id / e-mail / bank card (rules configurable); returns a masked copy, never mutates. | | createContentGuard | Prompt-injection heuristics for external content with reject / flag / downgrade policies. | | createApprovalService | Human-in-the-loop backend (request / approve / reject / list) with optional shared store and timeout → reject. createCallbackApprovalService drives MCP elicitation or a webhook. | | createRateLimiter | Sliding-window limiter, keyed by caller + tool. | | createAuditService | Redacted structured records (caller, target, argument summary, status, duration). |

Verify

npx jest test/regression/F-03 --coverage=false   # 18 cases
npx tsc -p tsconfig.json --noEmit

License

BSD-3-Clause

Approval migration (2026-09-30)

Always await service.approve(id) / await service.reject(id, reason); both return Promise<boolean>. Recovery is resume(id, { tool, caller, sessionId, requestId, args }, { signal }) and validates the original binding. Shared persistence omits raw args. maxLocalTickets bounds active requests, while consumed tombstones expire at their original deadline. Supply fresh unique IDs and a shared-store retention policy. See the monorepo docs/migration/phase-a-f-review-fixes.md for auditing/masking changes.