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

@molecule/api-ai-email-composer

v1.0.1

Published

AI-assisted email drafting with tone, length, and audience controls

Readme

@molecule/api-ai-email-composer

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

@molecule/api-ai-email-composer — AI-assisted email drafting.

Generates email drafts (subject + body) with tone / length / audience controls, plus an optional reply mode that grounds the draft in a previous message.

Quick Start

import { composeEmail } from '@molecule/api-ai-email-composer'

const draft = await composeEmail({
  brief: 'Tell the team the launch moved to Friday; apologize for the short notice.',
  tone: 'apologetic',
  length: 'short',
  audience: 'the engineering team',
  senderName: 'Priya',
})
// draft = { subject, body, reasoning? }

Type

utility

Installation

npm install @molecule/api-ai-email-composer @molecule/api-ai @molecule/api-bonds-default-express @molecule/api-database @molecule/api-i18n @molecule/api-middleware-validation

API

Interfaces

ComposeOptions

Options accepted by {@link composeEmail} to control the generated draft.

interface ComposeOptions {
  /** Plain-English description of what the email should say. */
  brief: string
  /** Tone preset. Default 'professional'. */
  tone?: EmailTone
  /** Length preset. Default 'medium'. */
  length?: EmailLength
  /** Who you're writing to (e.g. "the engineering team", "a vendor"). */
  audience?: string
  /** Optional prior message to reply to — anchors the response. */
  inReplyTo?: { from?: string; subject?: string; body: string }
  /** Sender name (for signature). */
  senderName?: string
  /** Pass-through to AI provider. */
  model?: string
}

EmailDraft

AI-generated email draft returned by {@link composeEmail}.

interface EmailDraft {
  subject: string
  body: string
  reasoning?: string
}

Types

EmailLength

Length preset controlling how many sentences / paragraphs the draft contains.

type EmailLength = 'short' | 'medium' | 'long'

EmailTone

Tone preset controlling the voice and register of the generated email.

type EmailTone =
  'professional' | 'friendly' | 'concise' | 'persuasive' | 'apologetic' | 'enthusiastic'

Functions

composeEmail(opts)

Generates an email draft (subject + body) from a plain-English brief using the wired AI provider.

function composeEmail(opts: ComposeOptions): Promise<EmailDraft>

Injection Notes

Requirements

Peer dependencies:

  • @molecule/api-bonds-default-express ^1.0.1
  • @molecule/api-database ^1.0.1
  • @molecule/api-i18n ^1.0.1
  • @molecule/api-middleware-validation ^1.0.1
  • @molecule/api-ai ^1.0.1

Runtime Dependencies

  • @molecule/api-ai
  • @molecule/api-bonds-default-express
  • @molecule/api-database
  • @molecule/api-i18n
  • @molecule/api-middleware-validation

Requires a bonded ai chat provider — composeEmail() resolves it via @molecule/api-ai's requireProvider() and throws if none is bonded. Wire one at startup (bond('ai', provider) or a named provider); with several named providers and no explicit default, resolution declines — see the @molecule/api-ai core docs.

Failure shape (no rejection): when the model returns non-JSON output — or the provider fails mid-call (API errors arrive as in-band error events, which this package does not treat as fatal) — the promise still RESOLVES with { subject: '(draft failed)', body: <raw model text or ''>, reasoning: 'malformed JSON' }. Check for that subject (or validate the draft) before sending anything automatically. Only a missing ai bond throws.