import { T as ToolHost } from '../tool-host-BqJRPr_T.js'; import { B as Bridge } from '../types-D_TzdBsK.js'; import '../types-ITRQFAir.js'; /** * Headless bridge for `@particle-academy/fancy-catalog` — a Stripe catalog with * NO UI surface. The adapter exposes the catalog's STORES + operations (not UI * getters/setters), and the tools are CRUD over products / prices + checkout + * Stripe sync. Mutations still funnel through `wrapToolWithActivity` so presence * + undo compose, and the destructive delete is `pendingMode`-gated. * * The adapter shapes below are STRUCTURAL mirrors of fancy-catalog's public * `Catalog` + store interfaces, defined LOCALLY so this bridge builds with the * sibling package absent (it's an optional peer). A real `Catalog` instance is * assignable to `CatalogBridgeAdapter` with no import — TypeScript is structural. */ /** Minimal product shape crossing the MCP wire (mirror of fancy-catalog `Product`). */ type CatalogProduct = { id: string; name: string; description?: string | null; active?: boolean; lookupKey?: string | null; externalId?: string | null; metadata?: Record | null; [k: string]: unknown; }; /** Minimal price shape crossing the MCP wire (mirror of fancy-catalog `Price`). */ type CatalogPrice = { id: string; productId: string; active?: boolean; currency: string; unitAmount: number; type: "recurring" | "one_time"; externalId?: string | null; [k: string]: unknown; }; /** Common checkout args (mirror of fancy-catalog `CheckoutArgs`). */ type CatalogCheckoutArgs = { customer?: string; successUrl: string; cancelUrl: string; metadata?: Record; /** One-time checkouts only. */ quantity?: number; }; /** * Adapter = the catalog instance / stores. A live `Catalog` from fancy-catalog * satisfies this directly (`catalog.products`, `catalog.createProduct`, …); a * host can also hand-roll one over its own persistence. */ type CatalogBridgeAdapter = { /** Stable id for this catalog instance (multiple catalogs ⇒ distinct ids). */ id?: string; /** Display label for logs / presence. */ title?: string; /** Optional fancy-screens screen id (usually unset — this is headless). */ screenId?: string; /** Product store — `catalog.products`. */ products: { find(id: string, opts?: { withTrashed?: boolean; }): CatalogProduct | null | Promise; all(opts?: { withTrashed?: boolean; }): CatalogProduct[] | Promise; remove(id: string): void | Promise; }; /** Price store — `catalog.prices`. */ prices: { find(id: string, opts?: { withTrashed?: boolean; }): CatalogPrice | null | Promise; forProduct(productId: string, opts?: { withTrashed?: boolean; }): CatalogPrice[] | Promise; all(opts?: { withTrashed?: boolean; }): CatalogPrice[] | Promise; remove(id: string): void | Promise; }; /** Authoring helpers — `catalog.createProduct` / `catalog.createPrice` (ULIDs auto-assigned). */ createProduct(input: Partial & { name: string; }): Promise | CatalogProduct; createPrice(input: Partial & { productId: string; currency: string; unitAmount: number; type: "recurring" | "one_time"; }): Promise | CatalogPrice; /** Stripe sync — `catalog.syncProductAndPrices`. Optional (no-op when absent). */ syncProductAndPrices?(product: CatalogProduct): Promise | CatalogProduct; /** Connection test — `catalog.testConnection`. Optional. */ testConnection?(): Promise<{ success: boolean; message: string; productCount?: number; }> | { success: boolean; message: string; productCount?: number; }; /** Hosted Checkout — `catalog.getSubscriptionCheckoutUrl` / `getOneTimeCheckoutUrl`. Optional. */ getSubscriptionCheckoutUrl?(price: CatalogPrice, args: CatalogCheckoutArgs): Promise | string; getOneTimeCheckoutUrl?(price: CatalogPrice, args: CatalogCheckoutArgs): Promise | string; }; type CatalogBridgeOptions = { adapter: CatalogBridgeAdapter; /** Identity stamped on activity + undo entries. */ agent?: { id: string; name?: string; color?: string; }; /** * Trust-but-verify. When on (default), destructive ops (`catalog_delete_product`, * `catalog_delete_price`) route through `adapter`-less staging: they require an * explicit `confirm: true` arg OR a host `confirm` callback. Read + create + * checkout-url tools are unaffected. */ pendingMode?: boolean; /** Host confirm hook for destructive ops (pendingMode). Resolves true to proceed. */ confirm?: (req: { action: string; id: string; label: string; }) => Promise | boolean; }; /** * registerCatalogBridge — full MCP tool set over a headless Stripe catalog. * * catalog_list_products list products ({ id, name, active, priceCount }) * catalog_get_product full product JSON + its prices * catalog_create_product create a product (ULID auto-assigned) * catalog_delete_product soft-delete a product (pendingMode-gated, undoable*) * catalog_list_prices list a product's prices (or all) * catalog_create_price create a price under a product * catalog_delete_price soft-delete a price (pendingMode-gated) * catalog_sync_product push a product + its prices to Stripe * catalog_test_connection verify the Stripe connection * catalog_create_checkout build a hosted Checkout URL for a price * * *delete undo is best-effort: stores expose soft-delete (`remove`) but no * un-delete, so the undo closure re-creates from the captured snapshot. */ declare function registerCatalogBridge(host: ToolHost, options: CatalogBridgeOptions): Bridge; export { type CatalogBridgeAdapter, type CatalogBridgeOptions, type CatalogCheckoutArgs, type CatalogPrice, type CatalogProduct, registerCatalogBridge };