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

tealtiger-copilotkit

v0.1.1

Published

Deterministic governance middleware for CopilotKit — action authorization, PII scanning, cost budgets, and structured audit trail

Downloads

62

Readme

tealtiger-copilotkit

Deterministic governance middleware for CopilotKit — action authorization, PII scanning, cost budgets, and structured audit trail.

No LLM in the governance path. All policy evaluation is deterministic, adding <2ms latency.

License

Installation

npm install tealtiger-copilotkit

Three-Layer Governance

| Layer | What it does | Where it runs | |-------|-------------|---------------| | Route Guard | Per-user/tenant budget check + cost recording | Next.js route handler (before/after CopilotKit runtime) | | Action Wrapper | Per-action authorization + PII scanning | Individual action handlers | | Content Scanner | PII detection/redaction on useCopilotReadable state | Before context enters the model |

Quick Start

1. Create the Governance Engine

import { TealTigerGovernance } from "tealtiger-copilotkit";

const governance = new TealTigerGovernance({
  mode: "ENFORCE", // OBSERVE | MONITOR | ENFORCE
  actionPolicy: {
    allowlist: ["searchDocs", "updatePreferences", "getAnalytics"],
    denylist: ["deleteAccount", "transferFunds", "exportAllData"],
  },
  pii: {
    scanReadable: true,
    scanActionArgs: true,
    action: "redact",
    categories: ["ssn", "credit_card", "api_key"],
  },
  budget: {
    perUser: 0.50,
    perTenant: 50.00,
  },
});

2. Route-Level Budget Guard

import { createRouteGuard } from "tealtiger-copilotkit";

const guard = createRouteGuard({
  governance,
  getUserId: (req) => req.headers.get("x-user-id") ?? undefined,
  getTenantId: (req) => req.headers.get("x-tenant-id") ?? undefined,
  costPer1kTokens: 0.003,
});

// Next.js App Router
export const POST = async (req: Request) => {
  // Check budget BEFORE processing
  const check = await guard.checkBudget(req);
  if (check.denied) return check.response; // 429

  // Process normally
  const response = await handleCopilotRequest(req);

  // Record usage AFTER
  await guard.recordUsage(req, response);
  return response;
};

3. Action Handler Wrapper

import { withTealTigerPolicy } from "tealtiger-copilotkit";

const actions = [
  {
    name: "deleteRecord",
    description: "Deletes a customer record",
    parameters: [{ name: "recordId", type: "string" }],
    handler: withTealTigerPolicy(
      { governance, actionName: "deleteRecord" },
      async ({ recordId }) => {
        // Only runs if governance allows
        return await db.delete(recordId);
      }
    ),
  },
];

4. Content PII Scanner

// Scan useCopilotReadable state before it enters the model
const userState = getUserData(); // may contain PII
const { text: safeState, decision } = await governance.scanContent(
  JSON.stringify(userState),
  userId,
  tenantId,
);

// safeState has PII redacted — safe to pass to copilot
// decision contains audit record of what was found

Governance Modes

| Mode | Behavior | |------|----------| | OBSERVE | Log all decisions but never block. PII findings recorded, actions still execute. | | MONITOR | Log + emit warnings. Actions still execute but decisions are flagged. | | ENFORCE | Block violating actions. PII redacted/blocked. Budget enforced with 429. |

Audit Trail

Every evaluation produces a structured GovernanceDecision:

{
  "correlationId": "550e8400-e29b-41d4-a716-446655440000",
  "timestamp": "2026-07-24T14:00:00.000Z",
  "action": "DENY",
  "mode": "ENFORCE",
  "reason": "Action 'deleteAccount' is in the denylist",
  "reasonCodes": ["ACTION_DENIED"],
  "riskScore": 80,
  "piiFindings": [],
  "costTracked": 0,
  "cumulativeCost": 0.42,
  "evaluationTimeMs": 0.8,
  "actionName": "deleteAccount",
  "userId": "user-123",
  "tenantId": "acme-corp"
}

Access via governance.getDecisions() or the onAudit callback.

PII Detection

Built-in deterministic patterns for:

  • Social Security Numbers (SSN)
  • Credit card numbers (Visa, Mastercard, Amex, Discover)
  • Email addresses
  • Phone numbers (US/international)
  • API keys (OpenAI, AWS, GitHub, GitLab)
  • IP addresses

License

Apache-2.0 — see LICENSE.