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

@alignment_agents/broker-protocol

v0.1.1

Published

TypeScript SDK for the Alignment Broker Protocol v0.1 — agent-to-agent commerce infrastructure

Readme

@alignment_agents/broker-protocol

TypeScript SDK for the Alignment Broker Protocol v0.1 — agent-to-agent commerce infrastructure.

npm version License: MIT


Overview

The Alignment Broker is the neutral settlement layer between Consumer Agents (shopping bots, voice assistants, phone-OS agents) and Brand Agents (product catalog endpoints). This SDK lets you build either side.

Consumer Agent  ──query──▶  Alignment Broker  ──fan-out──▶  Brand Agents
                ◀─quotes──                    ◀─quote────
                ──commit──▶                   ──commit──▶

Ranking is deterministic and transparent — no paid placement:

| Factor | Weight | |--------|--------| | Price match | 30% | | Trust score | 25% | | Semantic match | 20% | | Estimated delivery | 15% | | Inventory confidence | 10% |


Installation

npm install @alignment_agents/broker-protocol

Requires Node.js ≥ 18. Ships as ESM + CommonJS dual format with full TypeScript declarations.


Quick Start — Consumer Agent

import { AlignmentBroker } from "@alignment_agents/broker-protocol";

const broker = new AlignmentBroker({ apiKey: "ak_…" });

// 1. Query — find matching products across all Brand Agents
const result = await broker.query({
  consumer_agent_id: "did:alignment:acme:whatsapp-bot-1",
  intent: {
    raw: "waterproof running shoes under $150",
    structured: {
      category: "footwear",
      constraints: { waterproof: true, price_max: 150 },
    },
  },
  user_context: {
    region:           "US",
    currency:         "USD",
    ship_to_country:  "US",
  },
});

// 2. Inspect ranked quotes (transparent 5-factor score)
const top = result.ranked_quotes[0];
console.log(top.product.price, top.broker_score, top.ranking_factors);

// 3. Commit — confirm the purchase
const tx = await broker.commit({
  quote_id:          top.quote_id,
  consumer_agent_id: "did:alignment:acme:whatsapp-bot-1",
  shipping: {
    name:           "Jane Doe",
    address_line_1: "123 Main St",
    city:           "San Francisco",
    region:         "CA",
    postal_code:    "94105",
    country:        "US",
  },
  payment_token: "tok_visa_4242",   // tokenized payment, never raw PAN
  user_consent: {
    ts:                new Date().toISOString(),
    agent_attestation: "user-confirmed-on-whatsapp",
  },
});

console.log("Transaction ID:", tx.transaction_id);
console.log("Settlement:", tx.settlement);

Quick Start — Brand Agent Server

import { generateWellKnown, assertBrokerKey } from "@alignment_agents/broker-protocol";
import type { BrokerQuoteRequest, BrokerQuoteResponse } from "@alignment_agents/broker-protocol";

// 1. Serve your .well-known/agent.json discovery document
const wellKnown = generateWellKnown({
  agentId:   "did:alignment:my-brand:prod-1",
  operator:  "My Brand Inc.",
  baseUrl:   "https://agents.my-brand.com",
  currencies: ["USD", "EUR"],
  shipTo:    ["US", "CA", "GB"],
});

// 2. Handle /v1/quote calls from the Broker
async function handleQuote(req: BrokerQuoteRequest, brokerKey: string): Promise<BrokerQuoteResponse> {
  assertBrokerKey(brokerKey, process.env.BROKER_KEY!); // timing-safe validation

  return {
    brand_id:    "did:alignment:my-brand:prod-1",
    quote_id:    crypto.randomUUID(),
    price_usd:   129.99,
    currency:    "USD",
    product_id:  "shoe-wr-001",
    title:       "TrailRunner Pro — Waterproof",
    in_stock:    true,
    eta_days:    3,
    expires_at:  new Date(Date.now() + 5 * 60_000).toISOString(),
  };
}

API Reference

new AlignmentBroker(config)

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | — | Your Consumer Agent API key (ak_…) | | baseUrl | string | https://api.alignmenttech.ai | Broker API base URL | | timeoutMs | number | 15000 | Request timeout | | fetch | typeof fetch | global fetch | Custom fetch implementation |

Methods

| Method | Description | |--------|-------------| | broker.query(req) | Fan-out intent query → ranked quotes (p95 200–600 ms) | | broker.commit(req) | Confirm a quote → transaction + settlement | | broker.getQuery(queryId) | Replay / inspect a past query | | broker.registerConsumerAgent(req) | Register a new Consumer Agent | | broker.registerBrandAgent(req) | Register a new Brand Agent | | broker.setApiKey(key) | Update API key at runtime |

Error Classes

import {
  QuoteExpiredError,    // 409 — quote TTL elapsed (re-query)
  OutOfStockError,      // 410 — inventory gone
  AlreadyCommittedError,// 409 — quote already used
  RateLimitedError,     // 429 — slow down
} from "@alignment_agents/broker-protocol";

Get Your API Key

  1. Sign up at alignmenttech.ai
  2. Navigate to Agentic Commerce → Integration
  3. Copy your Consumer Agent API key

License

MIT © Alignment AI