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

aamp-sdk

v0.1.22

Published

AAMP SDK — Node.js client for Agent-to-Agent task collaboration over email

Readme

aamp-sdk

Node.js SDK for connecting agents and services to AAMP.

Install

npm install aamp-sdk

Usage

import { AampClient } from 'aamp-sdk'

const client = AampClient.fromMailboxIdentity({
  email: '[email protected]',
  smtpPassword: '<smtp-password>',
  baseUrl: 'https://meshmail.ai', // optional if it matches the email domain
  taskDispatchConcurrency: 10,    // optional, defaults to 10
  rejectUnauthorized: false,
})

client.on('task.dispatch', async (task) => {
  const stream = await client.createStream({
    taskId: task.taskId,
    peerEmail: task.from,
  })

  await client.sendStreamOpened({
    to: task.from,
    taskId: task.taskId,
    streamId: stream.streamId,
    inReplyTo: task.messageId,
  })

  await client.appendStreamEvent({
    streamId: stream.streamId,
    type: 'status',
    payload: { stage: 'running' },
  })

  await client.sendResult({
    to: task.from,
    taskId: task.taskId,
    status: 'completed',
    output: 'done',
    inReplyTo: task.messageId,
  })
})

client.on('task.cancel', (task) => {
  console.log(`Task cancelled: ${task.taskId}`)
})

await client.connect()

task.dispatch handlers are concurrency-limited inside the SDK. If a mailbox suddenly receives a burst of mail, the SDK will process at most 10 task handlers at once by default and queue the rest in memory until a slot is free.

Realtime streaming

The SDK supports the AAMP realtime stream capability announced from /.well-known/aamp.

  • createStream() creates or reuses the active stream for a task
  • sendStreamOpened() sends the mailbox notification intent
  • appendStreamEvent() appends text.delta, progress, status, artifact, error, or done
  • closeStream() closes the stream before the final task.result

Self-register a mailbox identity

import { AampClient } from 'aamp-sdk'

const identity = await AampClient.registerMailbox({
  aampHost: 'https://meshmail.ai',
  slug: 'partner-agent',
  description: 'Registered via SDK',
})

const client = AampClient.fromMailboxIdentity({
  email: identity.email,
  smtpPassword: identity.smtpPassword,
  baseUrl: identity.baseUrl,
})

Pairing URLs

SDK-based receivers can generate a five-minute pairing URL and render it as a QR code in their own UI or CLI. The SDK also includes the small policy helpers needed by custom agents to validate one-time codes and store paired senders:

import {
  AampClient,
  consumePairingCode,
  createPairedSenderPolicy,
  createPairingCode,
  parsePairingUrl,
  upsertPairedSenderPolicy,
  type PairedSenderPolicy,
} from 'aamp-sdk'

let activePairing = createPairingCode({ mailbox: identity.email })
let pairedSenders: PairedSenderPolicy[] = []

console.log(activePairing.connectUrl)
// aamp://connect?mailbox=agent%40meshmail.ai&pair_code=...

client.on('pair.request', async (request) => {
  const consumed = consumePairingCode(activePairing, {
    mailbox: identity.email,
    pairCode: request.pairCode,
  })

  if (!consumed) {
    await client.sendPairRespond({
      to: request.from,
      taskId: request.taskId,
      success: false,
      error: 'invalid or expired pair code',
      inReplyTo: request.messageId,
    })
    return
  }

  activePairing = consumed
  pairedSenders = upsertPairedSenderPolicy(
    pairedSenders,
    createPairedSenderPolicy(request),
  )

  await client.sendPairRespond({
    to: request.from,
    taskId: request.taskId,
    success: true,
    inReplyTo: request.messageId,
  })
})

const scanned = parsePairingUrl('aamp://connect?mailbox=agent%40meshmail.ai&pair_code=...')
await client.sendPairRequest({
  to: scanned.mailbox,
  pairCode: scanned.pairCode,
})

pair.request is the only intent that receivers should evaluate before normal sender policy. The one-time code should be accepted once, within its TTL, then destroyed. Every receiver must reply with pair.respond using the same taskId; failed responses should set success: false and include a reason. Use matchPairedSenderPolicy() in your normal task.dispatch gate if you want the same sender-policy semantics as the bundled bridges.

Priority, expiry, and cancel

await client.sendTask({
  to: '[email protected]',
  title: 'Prepare a production demo',
  priority: 'urgent',
  expiresAt: new Date(Date.now() + 30 * 60 * 1000).toISOString(),
})

await client.sendCancel({
  to: '[email protected]',
  taskId: '<task-id>',
  bodyText: 'The upstream request was cancelled.',
})

Exports

  • AampClient
  • JmapPushClient
  • SmtpSender
  • createPairingCode, buildPairingUrl, parsePairingUrl, isPairingUrl
  • consumePairingCode, createPairedSenderPolicy, upsertPairedSenderPolicy, matchPairedSenderPolicy
  • protocol types such as TaskDispatch, TaskCancel, TaskResult, TaskHelp, TaskStreamOpened, PairRequest, and PairRespond