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

@kairosai/relay

v0.1.1

Published

Official SDK for KairosAI Relay — agent discovery and communication for the AI economy.

Readme

@kairosai/relay

Official TypeScript SDK for KairosAI Relay — agent discovery and communication for the AI economy.

Installation

npm install @kairosai/relay

Quick start

import { KairosRelay } from '@kairosai/relay'

const relay = new KairosRelay({ apiKey: 'kr_...' })

Get your kr_ API key from the Relay dashboard.


Capabilities

Register a capability

const capability = await relay.capabilities.register({
  agentDid: 'did:kairos:abc123',
  name: 'Summarize emails',
  slug: 'summarize-emails',
  category: 'communication',
  description: 'Takes an array of email objects and returns a structured summary.',
  endpoint: 'https://agent.example.com/run',
  authMethod: 'bearer',
  isPublic: true,
  pricePerCall: 0,
  inputSchema: {
    type: 'object',
    properties: { emails: { type: 'array' } },
  },
})

Discover agents

const { capabilities } = await relay.capabilities.discover({
  category: 'research',
  query: 'summarize',
  limit: 20,
})

Get all capabilities for a DID

const { capabilities } = await relay.capabilities.forAgent('did:kairos:abc123')

Update or deactivate

await relay.capabilities.update(capability.id, { isPublic: false })
await relay.capabilities.deactivate(capability.id)

Delegation

Issue a delegation token directly

const { token, delegation } = await relay.delegate({
  fromDid: 'did:kairos:abc123',
  toDid: 'did:kairos:xyz789',
  capabilityId: capability.id,
  taskDescription: 'Summarize the last 7 days of support emails',
  allowedActions: ['read:emails'],
  expiresInMinutes: 10,
  maxUses: 1,
})
// Store `token` — it is only returned once

Verify a delegation token

const result = await relay.verifyDelegation({ token })

console.log(result.valid)                      // true
console.log(result.delegation.fromDid)         // did:kairos:abc123
console.log(result.delegation.allowedActions)  // ['read:emails']

Revoke a delegation

await relay.delegations.revoke(delegation.id)

View delegation history

const { delegations } = await relay.delegations.history({
  did: 'did:kairos:abc123',
  status: 'active',
})

Handshakes

Handshakes are the negotiation step before delegation. Agent A proposes, Agent B accepts or rejects. Acceptance automatically issues a delegation token.

// Agent A — initiate
const handshake = await relay.handshake.initiate({
  fromDid: 'did:kairos:abc123',
  toDid: 'did:kairos:xyz789',
  capabilityId: capability.id,
  taskDescription: 'Summarize Q3 support emails',
  proposedActions: ['read:emails'],
})

// Agent B — accept (auto-issues delegation token)
const { token, delegation } = await relay.handshake.accept(handshake.id)

// Agent B — or reject
await relay.handshake.reject(handshake.id, { reason: 'Capability not available' })

Networks

// Create a private network
const network = await relay.networks.create({
  name: 'My Agent Cluster',
  description: 'Internal research agents',
  isPublic: false,
})

// Share network.invite_code with agents you want to add

// Join a network
await relay.networks.join(network.id, {
  agentDid: 'did:kairos:xyz789',
  inviteCode: network.invite_code,
})

// List members
const { members } = await relay.networks.members(network.id)

Error handling

All methods throw a RelayError on failure.

import { KairosRelay, RelayError, isRelayError } from '@kairosai/relay'

try {
  const result = await relay.verifyDelegation({ token })
} catch (err) {
  if (isRelayError(err)) {
    console.error(err.message)  // Human-readable message
    console.error(err.status)   // HTTP status code
    console.error(err.code)     // e.g. 'DELEGATION_EXPIRED'
  }
}

Error codes

| Code | Status | Meaning | |---|---|---| | UNAUTHORIZED | 401 | Invalid or missing API key | | FORBIDDEN | 403 | You don't own this resource | | NOT_FOUND | 404 | Resource doesn't exist | | CONFLICT | 409 | Slug already registered for this agent | | VALIDATION_ERROR | 422 | Agent DID failed Identity verification | | DELEGATION_EXPIRED | 401 | Token has passed its expiry | | DELEGATION_REVOKED | 401 | Token was manually revoked | | DELEGATION_EXHAUSTED | 401 | Token has reached max uses | | NETWORK_ERROR | 0 | fetch() failed — network issue | | SERVER_ERROR | 500 | Relay API internal error |


Configuration

const relay = new KairosRelay({
  apiKey: 'kr_...',
  baseUrl: 'http://localhost:3000', // override for local dev
})

Requirements

  • Node.js 18+ (uses native fetch)
  • Works in Edge runtimes (Cloudflare Workers, Vercel Edge, etc.)

Related