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

@clgplatform/sdk

v1.5.0

Published

Official CLG SDK for decision receipt tracking in gateway, sidecar, and hybrid deployments.

Readme

@clgplatform/sdk

TypeScript/JavaScript SDK for CLG Platform (Causal Liability Gateway).

Installation

npm install @clgplatform/sdk

Quick start (5-line wrapAgent)

import { wrapAgent } from '@clgplatform/sdk';

const trackedAgent = wrapAgent(myAgentFunction, {
  apiUrl: process.env.CLG_URL || 'https://clgplatform.com',
  apiKey: process.env.CLG_API_KEY!,
  agentId: 'my-agent',
  workflowId: 'wf-001'
});

const result = await trackedAgent({ prompt: 'Hello' });

Quick start (CLGSidecar directly)

import { CLGSidecar } from '@clgplatform/sdk';

const clg = new CLGSidecar({
  apiUrl: process.env.CLG_URL || 'https://clgplatform.com',
  apiKey: process.env.CLG_API_KEY!,
  mode: 'gateway'
});

await clg.createReceipt({
  workflow_id: 'wf-001',
  task_id: 'task-001',
  agent_id: 'my-agent',
  task_input: { prompt: 'Hello' },
  output: { answer: 'Hi!' }
});

Deployment modes

  • gateway: sends cleartext payload to POST /v1/receipts for server-side signing.
  • sidecar: signs locally, then sends signed payload to POST /v1/receipts/signed.
  • hybrid: same transport as sidecar; useful when you locally sign but still centrally ingest.

Evaluate decision (new in 1.1.0)

evaluateDecision calls CLG mandate evaluation endpoint and returns an approve/deny decision plus a signed receipt.

import { CLGSidecar } from '@clgplatform/sdk';

const clg = new CLGSidecar({
  apiUrl: process.env.CLG_URL || 'https://clgplatform.com',
  apiKey: process.env.CLG_API_KEY!,
  mode: 'gateway'
});

const result = await clg.evaluateDecision({
  workflow_id: 'wf-001',
  task_id: 'task-001',
  agent_id: 'agent-001',
  mandate_ref: 'default',
  decision_type: 'tool-call',
  decision_value: 'invoice:create',
  task_input: { customerId: 'c-1' }
});

if (result.decision === 'deny') {
  console.log('Denied:', result.reason);
}

Sidecar and hybrid behavior for evaluateDecision

Even when running in sidecar or hybrid, evaluateDecision is sent to the CLG gateway endpoint because mandate resolution and tenant policy state are server-side concerns.

Chain positioning in sidecar/hybrid

createReceipt supports:

  • chain_position and optional workflow_depth (explicit control), or
  • previous_receipt_hashes (auto-resolve previous receipt from API and set chain_position = previous + 1).

Example (explicit):

await clg.createReceipt({
  workflow_id: 'wf-001',
  task_id: 'task-002',
  agent_id: 'my-agent',
  task_input: { step: 2 },
  output: { ok: true },
  chain_position: 2,
  workflow_depth: 2,
  previous_receipt_hashes: ['<receipt-hash-step-1>']
});

Environment variables example

CLG_URL=https://clgplatform.com
CLG_API_KEY=clg_live_xxxxx
CLG_MODE=gateway
CLG_LOCAL_SIGNING_KEY="-----BEGIN PRIVATE KEY-----..."
import { wrapAgent } from '@clgplatform/sdk';

const tracked = wrapAgent(agentFn, {
  apiUrl: process.env.CLG_URL!,
  apiKey: process.env.CLG_API_KEY!,
  mode: (process.env.CLG_MODE as 'gateway' | 'sidecar' | 'hybrid') || 'gateway',
  localSigningKey: process.env.CLG_LOCAL_SIGNING_KEY,
  agentId: 'agent-prod',
  workflowId: 'wf-prod-42'
});