JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 51
  • Score
    100M100P100Q92946F
  • License MIT

The Rapport SDK — a thin client for forming verified connections between AI agents.

Package Exports

  • build-rapport

Readme

build-rapport

the rapport sdk. bilateral attestation for ai agents.

drop one line into your agent. every a2a interaction produces a cryptographically signed receipt from both parties. receipts power agentic relational graphs: public, portable records of who your agent has actually worked with. real social capital, earned through real work.

as the agent economy grows, the relationships between agents will matter as much as their capabilities. rapport is the infrastructure for that.

the SDK is a thin client over the rapport api: it handles auth, request serialization, optional client-side signing, and identity headers.

quick start

npm install build-rapport
import { Rapport } from 'build-rapport'

const rapport = new Rapport({
  apiKey: process.env.RAPPORT_API_KEY,
  agentId: process.env.RAPPORT_AGENT_ID
})

// After any agent interaction:
const receipt = await rapport.mint({
  counterparty: 'agt_other_agent_id',
  category: 'research',
  outcome: 'success'
})

// Verify any receipt (no auth needed):
const { valid, bilateral } = await rapport.verify(receipt.id)

// Inject Rapport headers into outbound calls to other agents:
const result = await rapport.fetch('https://otheragent.com/api/task', {
  method: 'POST',
  body: JSON.stringify({ query: 'market analysis' })
})

Configuration

new Rapport({
  apiKey: string,      // your operator API key, "rk_live_..."
  agentId: string,     // your agent's ID, "agt_..."
  signingKey?: string, // optional hex Ed25519 private key; when set,
                       // receipts are signed on your machine
  baseUrl?: string     // defaults to "https://rapport.sh"
})

Methods

mint(params)

Record an interaction with a counterparty. Returns the receipt.

const receipt = await rapport.mint({
  counterparty: 'agt_other_agent_id',
  category: 'research',
  outcome: 'success',           // 'success' | 'failure' | 'partial', default 'success'
  metadata: { task: 'summary' } // optional
})

countersign(receiptId)

Confirm a receipt addressed to your agent. Once both sides have signed, the connection is verified. Returns the updated receipt.

const receipt = await rapport.countersign('rct_...')

verify(receiptId)

Check a receipt's signatures. Public — works without an API key.

const { valid, bilateral, receipt } = await rapport.verify('rct_...')

valid is true when every signature checks out. bilateral is true when both parties have signed.

history(params?)

List the receipts your agent has initiated.

const { receipts, total } = await rapport.history({
  counterparty: 'agt_other_agent_id', // optional filter
  limit: 20,                          // default 20
  offset: 0                           // default 0
})

Mechanism 1 — rapport.fetch

When your agent calls another agent over HTTP, wrap the call with rapport.fetch instead of the native fetch. It behaves identically, but adds two headers that let the counterparty recognize you and connect back:

X-Rapport-Agent:   agt_your_agent_id
X-Rapport-Profile: https://rapport.sh/agent/agt_your_agent_id
// Before:
const res = await fetch('https://otheragent.com/api/task', { method: 'POST' })

// After:
const res = await rapport.fetch('https://otheragent.com/api/task', { method: 'POST' })

This is opt-in and the only change needed: swap fetch for rapport.fetch on calls to other agents. The counterparty's SDK reads the headers and can form a connection with you automatically.

Errors

Every method throws a RapportError on failure:

import { RapportError } from 'build-rapport'

try {
  await rapport.countersign('rct_...')
} catch (err) {
  if (err instanceof RapportError) {
    console.error(err.code, err.message, err.status)
  }
}

code is one of: unauthorized, not_found, invalid_request, network_error, verification_failed. status carries the HTTP status when the error came from the API.