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

@trace-protocol/client

v0.1.2

Published

TRACE Protocol TypeScript SDK — Action → Policy → Evidence

Readme

@trace-protocol/client

npm version License

TypeScript SDK for TRACE Protocol

Open, vendor-neutral SDK for the TRACE Protocol's Action → Policy → Evidence loop.

  • 📦 Package: @trace-protocol/client
  • 🔌 Protocol: HTTP/JSON (/actions, /evidence, /policy)
  • 🧪 Minimal & testable: ESM-first, no heavy dependencies
  • 🧱 License: Apache-2.0

Install

npm i @trace-protocol/client
# or
pnpm add @trace-protocol/client
# or
yarn add @trace-protocol/client

Reference server (for local development):

cd server
npm i && npm run dev    # → http://localhost:8787

Quickstart

import { TraceClient } from "@trace-protocol/client";

const trace = new TraceClient({ endpoint: "http://localhost:8787" });

const decision = await trace.propose({
  type: "send_email",
  actor: { kind: "agent", name: "mail-bot", provider: "openai" },
  target: "mailto:[email protected]",
  params: { subject: "Pricing", body: "Hi!" },
});

if (decision.status === "requires_approval") {
  // dev shortcut: simulate approval on the reference server
  await fetch(`http://localhost:8787/approve/${decision.actionId}`, { method: "POST" });
}

await trace.evidence(decision.actionId, [
  { name: "email_sent", pass: true, note: "msgId=123" },
]);

High-level helper (withAction)

A convenience wrapper that does: propose → (optional approval) → run → evidence.

import { TraceClient, withAction } from "@trace-protocol/client";

const trace = new TraceClient({ endpoint: "http://localhost:8787" });

await withAction({
  trace,
  type: "send_email",
  actor: { kind: "agent", name: "mail-bot" },
  target: "mailto:[email protected]",
  params: { subject: "Pricing", body: "Hi!" },

  onApproval: async ({ actionId }) => {
    // dev shortcut — in prod: Slack, ticketing, etc.
    await fetch(`http://localhost:8787/approve/${actionId}`, { method: "POST" });
  },

  run: async () => {
    // perform the side effect (send email, open PR, etc.)
    return { id: "msg_123" };
  },

  evidence: {
    onSuccess: (res) => [{ name: "email_sent", pass: true, note: `id=${res.id}` }],
    onError:  (err) => [{ name: "email_failed", pass: false, note: String(err) }],
  },
});

API

new TraceClient(opts?: { endpoint?: string })

  • endpoint defaults to http://localhost:8787.

propose(input) → Promise<Decision & { actionId: string }>

Registers an Action and returns a Decision.

await trace.propose({
  type: "open_pr",
  actor: { kind: "agent", name: "repo-bot" },
  target: "github://org/repo#branch",
  params: { title: "feat: add X" },
});

Decision

type Decision = {
  actionId: string;
  status: "approved" | "rejected" | "requires_approval" | "observed";
  checks?: string[]; // names required before approval
}

evidence(actionId, checks) → Promise<{ verified: boolean }>

Attach Evidence checks to an action.

await trace.evidence("a_123", [
  { name: "reviewer_approval", pass: true, approver: "@admin" }
]);

policy(actionType?: string) → Promise<Policy>

Fetch compiled policy (server may filter by actionType).


Types

export interface Actor {
  kind: "agent" | "human" | "system";
  name: string;
  provider?: string;
}

export interface Action {
  id: string;
  type: string;
  actor: Actor;
  target?: string;
  params?: Record<string, unknown>;
  timestamp: string;
}

export interface Check {
  name: string;
  pass: boolean;
  approver?: string;
  note?: string;
}

export interface Evidence {
  actionId: string;
  checks: Check[];
  timestamp?: string;
}

export interface Decision {
  actionId: string;
  status: "approved" | "rejected" | "requires_approval" | "observed";
  checks?: string[];
}

export interface PolicyRule {
  when?: { actionType?: string };
  require?: string[];
  mode?: "enforce" | "observe";
}

export interface Policy {
  rules: PolicyRule[];
}

Examples

Working examples are available in the main repository:

  • examples/sendEmail.mjs - Low-level API usage
  • examples/sendEmail-withAction.mjs - High-level withAction helper
  • examples/lib/mailer.mjs - Shared utilities

Run the examples:

# Build the SDK (if using local development)
cd sdk/ts/client && npm install && npm run build

# Start the reference server
cd ../../server && npm install && npm run dev

# Run examples (from repository root)
node examples/sendEmail.mjs
node examples/sendEmail-withAction.mjs

Testing

This package uses Vitest.

npm -C sdk/ts/client i
npm -C sdk/ts/client run test

We keep TS build config separate from test config to avoid rootDir warnings. If your editor shows stale type errors, restart TS server.


Build & Publish

# build
npm -C sdk/ts/client run build

# preview tarball
npm -C sdk/ts/client pack --dry-run

# publish
npm -C sdk/ts/client publish --access public

Versioning

  • v0.1: observer mode + optional human-in-the-loop; Python parity
  • Roadmap: Checkers API (programmatic checks), signatures & hash-chain evidence

License

Apache-2.0 © TRACE Protocol — Stewards of the TRACE Protocol