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

@agentojs/core

v0.1.0

Published

Agentic middleware for AI commerce — connect any store to Claude (MCP), ChatGPT (ACP), and Gemini (UCP)

Downloads

123

Readme

@agentojs/core

npm version License: MIT

Core types and CommerceBackend interface for building AI commerce agent adapters.

Zero runtime dependencies -- pure TypeScript types and one interface.

Part of the AgentOJS monorepo.

Installation

npm install @agentojs/core
# or
pnpm add @agentojs/core

What's Included

  • CommerceBackend -- the unified interface that all adapters implement (19 methods)
  • Product, Cart, Order, Address, Region and 15+ supporting types
  • PaginatedResponse<T>, ProductSearchFilters, OrderListFilters -- query/response generics

This package contains no runtime code. It exists so adapters and consumers share the same type definitions.

Usage

Implementing a custom adapter

import type {
  CommerceBackend,
  Product,
  PaginatedResponse,
  ProductSearchFilters,
} from '@agentojs/core';

class MyCustomBackend implements CommerceBackend {
  async searchProducts(filters: ProductSearchFilters): Promise<PaginatedResponse<Product>> {
    const response = await fetch(`https://api.example.com/products?q=${filters.q}`);
    const data = await response.json();
    return { data: data.products, count: data.total, offset: filters.offset ?? 0, limit: filters.limit ?? 20 };
  }

  async getProduct(id: string): Promise<Product> {
    const response = await fetch(`https://api.example.com/products/${id}`);
    return response.json();
  }

  // ... implement remaining methods
}

Using types standalone

import type { Product, Cart, Order, Address } from '@agentojs/core';

function formatOrderSummary(order: Order): string {
  return `Order #${order.display_id}: ${order.items.length} items, total ${order.total} ${order.currency_code}`;
}

Writing backend-agnostic code

import type { CommerceBackend } from '@agentojs/core';

async function findCheapestProduct(backend: CommerceBackend, query: string) {
  const { data } = await backend.searchProducts({ q: query, limit: 50 });
  return data.sort((a, b) => {
    const priceA = a.variants[0]?.prices[0]?.amount ?? Infinity;
    const priceB = b.variants[0]?.prices[0]?.amount ?? Infinity;
    return priceA - priceB;
  })[0];
}

This function works with any adapter -- Medusa, WooCommerce, or a custom REST backend.

CommerceBackend Interface

The CommerceBackend interface defines 19 methods across 7 categories:

Products

| Method | Signature | Description | |--------|-----------|-------------| | searchProducts | (filters: ProductSearchFilters) => Promise<PaginatedResponse<Product>> | Search with text query, category/collection filters, price range, pagination | | getProduct | (id: string) => Promise<Product> | Get a single product by ID with variants and pricing | | getCollections | () => Promise<Collection[]> | List all product collections | | getCollection | (id: string) => Promise<Collection> | Get a single collection with its products |

Cart

| Method | Signature | Description | |--------|-----------|-------------| | createCart | (regionId: string, items: Array<{variant_id: string; quantity: number}>) => Promise<Cart> | Create a new cart with initial items | | getCart | (cartId: string) => Promise<Cart> | Retrieve cart by ID | | updateCart | (cartId: string, updates: {...}) => Promise<Cart> | Update email, shipping/billing address, metadata | | addLineItem | (cartId: string, variantId: string, quantity: number) => Promise<Cart> | Add a line item to cart | | removeLineItem | (cartId: string, lineItemId: string) => Promise<Cart> | Remove a line item from cart |

Shipping

| Method | Signature | Description | |--------|-----------|-------------| | getShippingOptions | (cartId: string) => Promise<ShippingOption[]> | Get available shipping options for a cart | | addShippingMethod | (cartId: string, optionId: string) => Promise<Cart> | Select a shipping method |

Checkout

| Method | Signature | Description | |--------|-----------|-------------| | createPaymentSessions | (cartId: string) => Promise<Cart> | Create payment sessions for cart | | selectPaymentSession | (cartId: string, providerId: string) => Promise<Cart> | Select a payment provider | | initializePayment | (cartId: string, providerId: string) => Promise<PaymentSession> | Initialize payment collection and session | | completeCart | (cartId: string) => Promise<Order> | Complete checkout, returns the created Order |

Orders

| Method | Signature | Description | |--------|-----------|-------------| | getOrder | (orderId: string) => Promise<Order> | Get order by ID | | listOrders | (filters: OrderListFilters) => Promise<PaginatedResponse<Order>> | List orders with email/status filters |

Regions

| Method | Signature | Description | |--------|-----------|-------------| | getRegions | () => Promise<Region[]> | List all store regions (currencies, countries) |

Health

| Method | Signature | Description | |--------|-----------|-------------| | healthCheck | () => Promise<boolean> | Check if the e-commerce backend is reachable |

Type Reference

Core Entities

| Type | Key Fields | |------|------------| | Product | id, title, description, handle, thumbnail, images, variants, options, categories, tags, status | | ProductVariant | id, title, sku, barcode, prices, options, inventory_quantity, weight | | Price | id, amount, currency_code, min_quantity, max_quantity | | Collection | id, title, handle, products | | Cart | id, items, region_id, currency_code, subtotal, tax_total, shipping_total, total, email, shipping_address | | LineItem | id, variant_id, product_id, title, quantity, unit_price, total | | Order | id, display_id, status, items, currency_code, total, email, shipping_address, fulfillments | | Address | first_name, last_name, address_1, city, province, postal_code, country_code | | Region | id, name, currency_code, countries | | ShippingOption | id, name, amount, region_id | | PaymentSession | id, provider_id, status, amount, currency_code |

Query/Response Types

| Type | Description | |------|-------------| | PaginatedResponse<T> | { data: T[], count, offset, limit } | | ProductSearchFilters | { q?, category_id[]?, collection_id[]?, tags[]?, price_min?, price_max?, limit?, offset? } | | OrderListFilters | { email?, status?, limit?, offset? } |

Available Adapters

License

MIT