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

@aimail/mail-core

v0.1.15

Published

AIMail shared TS core: gateway client, tool functions, inbound preprocess chain (framework-agnostic; single runtime dep: typebox).

Readme

@aimail/mail-core

Framework-agnostic AIMail core for TypeScript: gateway HTTP client, mail / contact / note / board tool functions, the full inbound preprocess chain, and agentmail.json read/write. Only dependency: typebox (parameter schemas) — import it directly from any TS agent runtime (dsh, OpenClaw, pi, or your own).

npm

Install

pnpm add @aimail/mail-core

Point AIMAIL_HOME at your aimail home directory (default ~/.aimail), where per-address agentmail.json bindings live.

What it does

  • GatewayClient — authenticated HTTP client for the AIMail gateway (send / upload / download / whitelist / contacts / agent-state / threads / boards). Outbound requests carry the X-AIMail-Agent identity header and are signed with the v1 HMAC scheme.
  • Tool functions — sendMail, manageContacts, contactProfile, setContactProfile, emailSummary, setEmailSummary, searchMail, plus the board API (boardStatus, boardTaskList, boardTaskShow, boardHeartbeat, boardMembers, setPublicWhoami, activateAddressCode).
  • Inbound chain — processInboundMail runs the full inbound preprocess (recipient/sender enrichment, persona normalization, direct-message and mention detection, attachment download, backend-field stripping, inbound logging) and intercepts ping/pong health probes; verifySignature checks webhook HMAC signatures.
  • MAIL_TOOLS — the semantic registry of all 15 tools (names, descriptions, TypeBox parameter shapes, handlers). Adapters iterate this single array so every platform surfaces an identical tool surface.
  • Config loaders — loadConfigByEmail, loadConfigByAgentId, loadConfigBySessionId, saveAgentConfig, updateAgentConfig (per-address agentmail.json is the sole identity source).
  • Identity — setAgentIdentity / setAgentModel set the outbound X-AIMail-Agent header ({platform}/{version}+{model}).

Usage sketch

import { sendMail, processInboundMail, verifySignature, MAIL_TOOLS } from '@aimail/mail-core'

// send (tool functions take a ToolCtx resolved from agentmail.json)
const result = await sendMail({ systemId, email }, { to, subject, body })

// inbound (HMAC-verified payload from the aimail-bridge)
if (verifySignature(rawBody, sig, webhookSecret)) {
  const enriched = await processInboundMail(payload, headers, { systemId, email })
  if (enriched === null) {
    // ping/pong intercepted — already answered
  } else {
    // deliver enriched JSON into the agent session
  }
}

// adapter registration: iterate the semantic registry
for (const tool of MAIL_TOOLS) { /* bind name/description/params/handler */ }

API notes

  • processInboundMail returns null when the mail was a ping/pong probe (the chain answers it in-place); otherwise it returns the enriched payload to hand to the agent.
  • verifySignature compares a timing-safe HMAC-SHA256 of the raw body against the X-Webhook-Signature header, keyed by the per-address webhook_secret.
  • The inbound chain is the inbound contract (not an optional preprocessing layer): every platform adapter must call it before handing mail to the agent.

Related repositories

  • metercai/aimail — the AIMail monorepo: CLI (cli/), Python SDK (pysdk/), TypeScript SDK (tssdk/), bridge distributions.
  • metercai/aimail-gateway — the AIMail gateway: SMTP/HTTP mail service, address & activation APIs, and the board endpoints the SDK client talks to.