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

@loom-loyalty/ai-sdk

v0.1.1

Published

Vercel AI SDK tools that let a storefront's shopper chat answer loyalty questions from Loom Loyalty

Readme

@loom-loyalty/ai-sdk

Vercel AI SDK tools that let your storefront's shopper chat answer loyalty questions from Loom Loyalty: "How many points do I have?", "What tier am I?", "Do I have any coupons?"

The tools are read-only and scoped to one shopper. Your server decides who the shopper is and passes their id; the model can never pick a different customer.

Install

npm install @loom-loyalty/ai-sdk ai zod

Works with AI SDK 5 through 7 (tested on 5 and 7).

Set up an API key

  1. In the Loom Loyalty dashboard, go to Developers → API Keys and create a key.
  2. Open Manage Roles on it and leave it only a read-only role, such as AI Bot. The tools only read, so the key doesn't need write access.
  3. Set these on your server. Never send the key to the browser.
LOOM_LOYALTY_API_URL=https://api.loomloyalty.com
LOOM_LOYALTY_API_KEY=...

This is a server-to-server integration. Loom Loyalty does not sign shoppers in; your app's own session says who the shopper is.

Use it

import { memberTools } from "@loom-loyalty/ai-sdk";
import { streamText } from "ai";

export async function POST(req: Request) {
  const shopper = await getSignedInShopper(req); // your auth
  const { messages } = await req.json();

  const result = streamText({
    model: "anthropic/claude-sonnet-5.5",
    system:
      "You are the store's assistant. Use the loyalty tools for questions about points, tier and offers.",
    messages,
    tools: memberTools({ customerExternalId: shopper.id }),
  });
  return result.toUIMessageStreamResponse();
}

customerExternalId is the shopper's id in your system, as stored on their Loom Loyalty customer record (externalId).

Tools

None of the tools take input. Each one reads the shopper named by customerExternalId and nobody else.

| Tool | Returns | | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | | getMyPoints | { programs: [{ program, currency, available, pending }] } | | getMyTier | { tiers: [{ tier, nextTier? }] } | | getMyOffers | { offers: [{ name, code?, validFrom?, validUntil? }] }: coupons the shopper can use now (not used, held, cancelled or expired). Times are ISO 8601 in UTC. |

Options

| Option | Default | | | -------------------- | ---------------------- | ----------------------------------------------------------- | | customerExternalId | required | The signed-in shopper's id in your system. | | apiUrl | LOOM_LOYALTY_API_URL | | | apiKey | LOOM_LOYALTY_API_KEY | Use a read-only key. | | timeoutMs | 10000 | Per tool call. | | client | | A MemberClient to use instead of building one, for tests. |

memberTools throws LoomLoyaltyConfigError when the shopper id, URL or key is missing.

Errors

Tools never throw. A failure comes back as { error } with a fixed message the model can pass on, such as "Member not found." or "Loom Loyalty is busy. Try again in a moment.". Messages never include the API's own error text, so the key can't leak into the chat.

Admin assistants

For staff-facing assistants that manage programs and customers, connect the Loom Loyalty MCP server instead. See the docs: Connect AI assistants.