@relyon/kit 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/AGENTS.md +75 -0
  2. package/CHANGELOG.md +1053 -0
  3. package/LICENSE +21 -0
  4. package/QUICKSTART.md +239 -0
  5. package/README.md +117 -2
  6. package/dist/adapters/express.d.ts +39 -0
  7. package/dist/adapters/express.js +106 -0
  8. package/dist/adapters/hono.d.ts +16 -0
  9. package/dist/adapters/hono.js +15 -0
  10. package/dist/adapters/next.d.ts +29 -0
  11. package/dist/adapters/next.js +38 -0
  12. package/dist/agent-card.d.ts +14 -0
  13. package/dist/agent-card.js +58 -0
  14. package/dist/agent-docs.d.ts +36 -0
  15. package/dist/agent-docs.js +78 -0
  16. package/dist/agent-hooks.d.ts +66 -0
  17. package/dist/agent-hooks.js +280 -0
  18. package/dist/agents.d.ts +24 -0
  19. package/dist/agents.js +120 -0
  20. package/dist/api-key.d.ts +6 -0
  21. package/dist/api-key.js +33 -0
  22. package/dist/cache.d.ts +46 -0
  23. package/dist/cache.js +86 -0
  24. package/dist/cart-tokens.d.ts +31 -0
  25. package/dist/cart-tokens.js +58 -0
  26. package/dist/cart-transfer.d.ts +95 -0
  27. package/dist/cart-transfer.js +387 -0
  28. package/dist/catalog-enrichment.d.ts +6 -0
  29. package/dist/catalog-enrichment.js +71 -0
  30. package/dist/catalog-reads.d.ts +126 -0
  31. package/dist/catalog-reads.js +104 -0
  32. package/dist/catalog.d.ts +78 -0
  33. package/dist/catalog.js +288 -0
  34. package/dist/charge-claims.d.ts +11 -0
  35. package/dist/charge-claims.js +47 -0
  36. package/dist/check.d.ts +44 -0
  37. package/dist/check.js +152 -0
  38. package/dist/checklist-manifest.d.ts +72 -0
  39. package/dist/checklist-manifest.js +341 -0
  40. package/dist/checkout.d.ts +222 -0
  41. package/dist/checkout.js +353 -0
  42. package/dist/cli.d.ts +2 -0
  43. package/dist/cli.js +727 -0
  44. package/dist/confirmation.d.ts +78 -0
  45. package/dist/confirmation.js +124 -0
  46. package/dist/context.d.ts +81 -0
  47. package/dist/context.js +10 -0
  48. package/dist/discovery.d.ts +151 -0
  49. package/dist/discovery.js +346 -0
  50. package/dist/doctor-cart-transfer.d.ts +33 -0
  51. package/dist/doctor-cart-transfer.js +186 -0
  52. package/dist/doctor-catalog.d.ts +8 -0
  53. package/dist/doctor-catalog.js +47 -0
  54. package/dist/doctor-evidence.d.ts +22 -0
  55. package/dist/doctor-evidence.js +57 -0
  56. package/dist/doctor-merchant.d.ts +48 -0
  57. package/dist/doctor-merchant.js +74 -0
  58. package/dist/doctor-source.d.ts +5 -0
  59. package/dist/doctor-source.js +142 -0
  60. package/dist/doctor-variants.d.ts +70 -0
  61. package/dist/doctor-variants.js +102 -0
  62. package/dist/doctor.d.ts +215 -0
  63. package/dist/doctor.js +1689 -0
  64. package/dist/events.d.ts +95 -0
  65. package/dist/events.js +200 -0
  66. package/dist/feed-mapping.d.ts +114 -0
  67. package/dist/feed-mapping.js +152 -0
  68. package/dist/feed-values.d.ts +13 -0
  69. package/dist/feed-values.js +40 -0
  70. package/dist/feeds.d.ts +104 -0
  71. package/dist/feeds.js +366 -0
  72. package/dist/identify.d.ts +102 -0
  73. package/dist/identify.js +124 -0
  74. package/dist/identity.d.ts +37 -0
  75. package/dist/identity.js +54 -0
  76. package/dist/index.d.ts +42 -0
  77. package/dist/index.js +41 -0
  78. package/dist/init.d.ts +157 -0
  79. package/dist/init.js +912 -0
  80. package/dist/kit-config.d.ts +19 -0
  81. package/dist/kit-config.js +43 -0
  82. package/dist/kit-environment.d.ts +20 -0
  83. package/dist/kit-environment.js +32 -0
  84. package/dist/kit-updates.d.ts +47 -0
  85. package/dist/kit-updates.js +77 -0
  86. package/dist/kit-version-project.d.ts +18 -0
  87. package/dist/kit-version-project.js +214 -0
  88. package/dist/kit-version.d.ts +37 -0
  89. package/dist/kit-version.js +162 -0
  90. package/dist/kit.d.ts +516 -0
  91. package/dist/kit.js +1309 -0
  92. package/dist/layers/pages.d.ts +3 -0
  93. package/dist/layers/pages.js +5 -0
  94. package/dist/layers/payments.d.ts +7 -0
  95. package/dist/layers/payments.js +9 -0
  96. package/dist/layers/products.d.ts +10 -0
  97. package/dist/layers/products.js +13 -0
  98. package/dist/live.d.ts +13 -0
  99. package/dist/live.js +52 -0
  100. package/dist/mcp.d.ts +270 -0
  101. package/dist/mcp.js +312 -0
  102. package/dist/next-steps.d.ts +101 -0
  103. package/dist/next-steps.js +257 -0
  104. package/dist/order-pending.d.ts +57 -0
  105. package/dist/order-pending.js +127 -0
  106. package/dist/orders.d.ts +12 -0
  107. package/dist/orders.js +21 -0
  108. package/dist/payments-init.d.ts +19 -0
  109. package/dist/payments-init.js +70 -0
  110. package/dist/payments-routes.d.ts +54 -0
  111. package/dist/payments-routes.js +123 -0
  112. package/dist/payments.d.ts +165 -0
  113. package/dist/payments.js +192 -0
  114. package/dist/pnpm-workspace.d.ts +58 -0
  115. package/dist/pnpm-workspace.js +250 -0
  116. package/dist/policies.d.ts +111 -0
  117. package/dist/policies.js +317 -0
  118. package/dist/preview-hosts.d.ts +64 -0
  119. package/dist/preview-hosts.js +175 -0
  120. package/dist/private-config.d.ts +169 -0
  121. package/dist/private-config.js +820 -0
  122. package/dist/progress.d.ts +54 -0
  123. package/dist/progress.js +153 -0
  124. package/dist/protocol-inputs.d.ts +22 -0
  125. package/dist/protocol-inputs.js +151 -0
  126. package/dist/public-origin.d.ts +50 -0
  127. package/dist/public-origin.js +180 -0
  128. package/dist/refusals.d.ts +86 -0
  129. package/dist/refusals.js +157 -0
  130. package/dist/relay.d.ts +107 -0
  131. package/dist/relay.js +655 -0
  132. package/dist/release-notes.d.ts +2 -0
  133. package/dist/release-notes.js +290 -0
  134. package/dist/relyon-cart-tokens.d.ts +101 -0
  135. package/dist/relyon-cart-tokens.js +521 -0
  136. package/dist/relyon.d.ts +141 -0
  137. package/dist/relyon.js +238 -0
  138. package/dist/robots.d.ts +27 -0
  139. package/dist/robots.js +127 -0
  140. package/dist/rules.d.ts +144 -0
  141. package/dist/rules.js +347 -0
  142. package/dist/sdk/generated/public-api.d.ts +4816 -0
  143. package/dist/sdk/generated/public-api.js +1 -0
  144. package/dist/sdk/index.d.ts +24 -0
  145. package/dist/sdk/index.js +34 -0
  146. package/dist/sdk/signatures.d.ts +17 -0
  147. package/dist/sdk/signatures.js +33 -0
  148. package/dist/setup.d.ts +37 -0
  149. package/dist/setup.js +94 -0
  150. package/dist/signatures.d.ts +112 -0
  151. package/dist/signatures.js +443 -0
  152. package/dist/state.d.ts +185 -0
  153. package/dist/state.js +96 -0
  154. package/dist/store-payments.d.ts +48 -0
  155. package/dist/store-payments.js +143 -0
  156. package/dist/structured-fields.d.ts +26 -0
  157. package/dist/structured-fields.js +200 -0
  158. package/dist/templates.d.ts +19 -0
  159. package/dist/templates.js +193 -0
  160. package/dist/test-checkout-command.d.ts +32 -0
  161. package/dist/test-checkout-command.js +161 -0
  162. package/dist/test-checkout.d.ts +88 -0
  163. package/dist/test-checkout.js +292 -0
  164. package/dist/types.d.ts +103 -0
  165. package/dist/types.js +18 -0
  166. package/dist/ucp-versions.d.ts +57 -0
  167. package/dist/ucp-versions.js +129 -0
  168. package/dist/util.d.ts +23 -0
  169. package/dist/util.js +68 -0
  170. package/dist/variants.d.ts +67 -0
  171. package/dist/variants.js +146 -0
  172. package/dist/version.d.ts +9 -0
  173. package/dist/version.js +10 -0
  174. package/dist/waiting.d.ts +43 -0
  175. package/dist/waiting.js +57 -0
  176. package/dist/webhook-command.d.ts +48 -0
  177. package/dist/webhook-command.js +367 -0
  178. package/dist/webhook-registration.d.ts +47 -0
  179. package/dist/webhook-registration.js +69 -0
  180. package/dist/webmcp-schema.d.ts +14 -0
  181. package/dist/webmcp-schema.js +140 -0
  182. package/dist/webmcp-script.d.ts +3 -0
  183. package/dist/webmcp-script.js +176 -0
  184. package/dist/webmcp-store.d.ts +102 -0
  185. package/dist/webmcp-store.js +116 -0
  186. package/dist/webmcp.d.ts +242 -0
  187. package/dist/webmcp.js +866 -0
  188. package/dist/wire-names.d.ts +85 -0
  189. package/dist/wire-names.js +109 -0
  190. package/package.json +118 -4
  191. package/release-notes.json +290 -0
  192. package/scripts/install-notice.cjs +7 -0
  193. package/skills/relyon-agents/SKILL.md +327 -0
  194. package/skills/relyon-catalog/SKILL.md +499 -0
  195. package/skills/relyon-catalog/references/example-store.md +218 -0
  196. package/skills/relyon-checkout/SKILL.md +603 -0
  197. package/skills/relyon-checkout/references/checkout-flow.md +257 -0
  198. package/skills/relyon-checkout/references/checkout-page.md +315 -0
  199. package/skills/relyon-go-live/SKILL.md +344 -0
  200. package/skills/relyon-orders/SKILL.md +191 -0
  201. package/skills/relyon-orders/references/webhook-receiver.md +113 -0
  202. package/skills/relyon-payments/SKILL.md +117 -0
  203. package/skills/relyon-setup/SKILL.md +1061 -0
  204. package/skills/relyon-setup/references/QUICKSTART.md +239 -0
  205. package/skills/relyon-setup/references/durable-state.md +209 -0
  206. package/skills/relyon-setup/references/express-server.md +388 -0
  207. package/skills/relyon-setup/references/next-app-router.md +251 -0
  208. package/templates/common/STORE-README.md +67 -0
  209. package/templates/common/gitignore +8 -0
  210. package/templates/common/scripts/check-pricing.ts +22 -0
  211. package/templates/common/scripts/serve.mjs +13 -0
  212. package/templates/common/server/catalog.ts +79 -0
  213. package/templates/common/server/checkout-flow.d.ts +34 -0
  214. package/templates/common/server/pages.ts +184 -0
  215. package/templates/common/server/storage.ts +114 -0
  216. package/templates/common/server/store.ts +67 -0
  217. package/templates/express/server/express.ts +20 -0
  218. package/templates/express/tsconfig.build.json +6 -0
  219. package/templates/express/tsconfig.json +9 -0
  220. package/templates/next/app/[[...path]]/route.ts +24 -0
  221. package/templates/next/next.config.mjs +19 -0
  222. package/templates/next/tsconfig.json +12 -0
  223. package/templates/payments/express.ts +39 -0
  224. package/templates/payments/next.ts +38 -0
  225. package/templates/payments/node.ts +39 -0
@@ -0,0 +1,499 @@
1
+ ---
2
+ name: relyon-catalog
3
+ description: Keep products and prices in the store, supply catalog.source listProducts/getProduct callbacks for store-owned feeds and discovery, sync the index agent checkout buys from, and preserve merchant robots restrictions.
4
+ ---
5
+
6
+ # Relyon catalog
7
+
8
+ <!-- BEGIN relyon-store-first-rules (generated from the shared rules source; edit it there) -->
9
+ Before building, ask the user: 'Do you want to (1) accept card payments in your own app — no Relyon product catalog or shopping pages; (2) also list products so AI shopping agents can find and buy them; or (3) also have Relyon's kit build the shopping pages for you?' Don't choose for them. Then follow the matching quickstart.
10
+
11
+ ## Choose the integration before applying kit guidance
12
+
13
+ Payments: https://core.getrelyon.com/docs/payments-quickstart and `relyon-payments`.
14
+ Products and agent selling: https://core.getrelyon.com/docs (catalog,
15
+ agent checkout and AI visibility are optional additions).
16
+ Shopping pages: https://core.getrelyon.com/docs/quickstart and `relyon-setup`.
17
+ Never install the kit or build catalog, /cart or shopping pages for payments only.
18
+ The kit-specific rules below apply only after the user chooses shopping pages.
19
+ Live payments support human buyers and agents in every integration after staff
20
+ approval and processor onboarding, with existing payment safety checks intact.
21
+ Keep the secret key server-side as RELYON_API_KEY; only the publishable key is public.
22
+
23
+ When using the optional kit and uncertain about its version, run `npm view @relyon/store-kit version`.
24
+ Compare it with the store project's actually installed version; never downgrade.
25
+ Install the exact returned version with the project's package manager (npm install
26
+ --save-exact, pnpm add --save-exact, yarn add --exact, or bun add --exact), then run
27
+ `npx @relyon/store-kit doctor` afterward. If the lookup fails, say it is unavailable;
28
+ do not guess a latest version. Respect package-age holds without changing settings.
29
+
30
+ ## Test setup and hand-over
31
+
32
+ - Start the store as a separate detached background process, using the host's
33
+ process manager or `setsid nohup npm run start >store.log 2>&1 < /dev/null &`.
34
+ Never run it in the agent's own foreground session. Stop a recorded PID;
35
+ never use a `pkill` pattern that can match the shell issuing it.
36
+ - On a public Test URL, call `kit.ensureDomain(hostname)` and then
37
+ `kit.verifyDomain(domain.hostname)` after the verification route is reachable.
38
+ Domain verification is not only for Live.
39
+ - Say exactly “Test mode: no real money moves” when handing over a Test store.
40
+ Never say shoppers can buy or pay for real while the store is in Test.
41
+ - Server-only `loadTestConfig` supplies both `apiKey` and `webhookSecret`.
42
+ Wire them into `relyon.apiKey` and `rules.webhookSecret`; never expose either
43
+ in browser code or agent prompts.
44
+ - With an environment API key, `webhook` never writes a secret file.
45
+ A set `RELYON_WEBHOOK_SECRET` in environment or dotenv overrides key-only
46
+ runtime recovery. Unset it, or update it in host settings, then restart.
47
+ Rotation exits 1 if an override differs from the current secret. Do not
48
+ treat that exit as a failed rotation: the endpoint may already be rotated.
49
+ Never read or print the override value; never ask for it in an agent prompt.
50
+
51
+ ## Relyon store-first rules
52
+
53
+ These seven kit rules are identical in every Relyon skill. They apply only to the shopping-pages integration, never to payments-only apps.
54
+
55
+ 1. Install `@relyon/store-kit@0.1.52` from npm and mount its handlers on the app's own server (Express `@relyon/store-kit/express`, Next.js `@relyon/store-kit/next`, Hono `@relyon/store-kit/hono`).
56
+ 2. Catalog, cart and pricing stay in the app: the app owns `listProducts`, `getProduct`, `priceCart` and `createOrder`. Relyon never prices a cart. It charges exactly the final amount the store sends.
57
+ 3. Checkout runs on the store's own domain. The only Relyon element in the shopper's browser is the card fields component. Card numbers never touch the app's code, server or logs.
58
+ 4. The app calls Relyon only from its server, and only for payment, agent verification, fraud and limits, and recording.
59
+ 5. Agent activity reporting stays on: never stub, disable or throttle-to-zero the kit's event reporting.
60
+ 6. Start in Test. Live is enabled by Relyon staff, never approved by the agent; after staff approval, the agent activates it at the merchant's explicit instruction (set the env vars by name, redeploy, run the Live doctor for shopping pages) and never asks for or pastes a Live secret key. Build before requesting keys: missing credentials defer credential-dependent verification, never the local build. Show checkout as **waiting for a Test secret key**, record pending checks honestly, and resume them after configuring a real Test secret key without rebuilding. Never fabricate a credential, payment or order.
61
+ 7. No Relyon-hosted checkout, redirect to a Relyon page, CNAME, proxy, forwarding Worker or `quote.request`/pricing endpoint.
62
+
63
+ ### Test defaults — not merchant policy
64
+
65
+ | Item | Test default |
66
+ | --- | --- |
67
+ | Brand | Store name, unless the merchant supplies another brand. |
68
+ | MPN | SKU, unless the merchant supplies another MPN. |
69
+ | Stock | Available unless told otherwise; no invented inventory count. |
70
+ | Returns/support | Pending merchant items. Never invent them or submit placeholders as real policy data. |
71
+
72
+ Explicit merchant facts override these Test defaults. Proceed with local Test
73
+ building; ask before asserting missing merchant promises or syncing policies.
74
+ Never invent supplier claims, GTINs, tax treatment or policy terms. Pending
75
+ merchant information blocks only the checks that require it, not the build.
76
+ <!-- END relyon-store-first-rules -->
77
+
78
+ Reference only. Open a section when the quick start names it; no whole-skill prerequisite.
79
+
80
+ Contract: the approved public v1 contract dated **2026-10-30**, at
81
+ `https://core.getrelyon.com/v1/openapi.yaml` (another deployment:
82
+ `<service origin>/v1/openapi.yaml`). The kit calls it; the app doesn't need to.
83
+
84
+ The canonical API base is `https://core.getrelyon.com/api`; `/v1/products`
85
+ therefore means `https://core.getrelyon.com/api/v1/products`. The download URL
86
+ above and the store's own routes are separate. Retain operator-confirmed API
87
+ base overrides for other deployments.
88
+
89
+ ## Importing the merchant's products
90
+
91
+ For catalog implementation, use the shared Test defaults first. Ask the merchant
92
+ for their product data: a CSV or spreadsheet export, the supplier's records,
93
+ or the list itself. Write an importer that reads it into the app's own
94
+ products table, checks every required field below, and reports rows it
95
+ skipped instead of filling gaps. Read the store idea in
96
+ `relyon-store-brief.md` for what the store sells, but take titles, prices,
97
+ stock, images and supplier facts from merchant data or the shared Test defaults.
98
+ Never use a Test default as a verified supplier fact. Run the
99
+ importer again whenever the data changes; nothing needs to be sent to Relyon.
100
+
101
+ ## The app owns the catalog
102
+
103
+ The products, prices, stock, options, coupons, shipping and tax all live in the
104
+ app's own data. Write two plain functions in the app (they are the app's code,
105
+ not kit hooks):
106
+
107
+ - `listProducts()`: every product the store sells, in the shape below.
108
+ - `getProduct(id)`: one product, or `null`.
109
+
110
+ The app's product pages, its cart and `priceCart` (see `relyon-checkout`) read
111
+ the same data. A complete example is in
112
+ [the example store](references/example-store.md).
113
+
114
+ Each product uses the contract's `ProductInput` fields plus
115
+ `merchant_product_id`, the app's own product ID. When it is missing, the kit
116
+ fills it from the product's `id` (or `sku`) and still refuses duplicates; a
117
+ product with none of the three is refused:
118
+
119
+ ```json
120
+ {
121
+ "merchant_product_id": "lavender-candle",
122
+ "title": "Lavender candle",
123
+ "description": "Hand-poured soy candle with lavender oil. 40-hour burn.",
124
+ "url": "https://shop.example.com/products/lavender-candle",
125
+ "images": ["https://shop.example.com/images/lavender-candle.jpg"],
126
+ "from_price": { "amount": 2400, "currency": "USD" },
127
+ "availability": "in_stock"
128
+ }
129
+ ```
130
+
131
+ - `title`, `description`, `url`, `images`, `from_price` and `availability` are
132
+ needed for a product to be published. A product missing one is stored as
133
+ `rejected`, with an issue for each field.
134
+ - Agent checkout through Google (UCP) and ChatGPT (ACP) also needs `brand`
135
+ and a `gtin` or `mpn` in the index; without them the product is refused
136
+ with `product_not_checkout_eligible` (`missing_fields`). Use only the
137
+ merchant's own brand and identifiers, or the shared Test defaults in Test.
138
+ - `url` is the product page on the store's own domain.
139
+ - `from_price` is display only: the lowest price a shopper could pay. It is
140
+ never charged.
141
+ - Set `configurable: true` and describe `options` when the shopper must make
142
+ choices the app prices (bundles, add-ons, sizes). Agents then pass the
143
+ choices on the cart line, and `priceCart` validates them.
144
+ - No card data, secrets or customer data in any product field.
145
+ - Fill `category` and `attributes` for every product from its actual product
146
+ data. A category is a product type path, for example
147
+ `Home & Garden > Kitchen & Dining > Tableware > Drinkware > Mugs`.
148
+ Never invent a missing category; add it to the product data, then sync again.
149
+ Attributes allow only `color`, `size`, `material`, `gender` and `age_group`.
150
+ When attributes are empty, the kit derives them from readable options and
151
+ `feed.variants` options, including colour/size aliases and all values.
152
+ Explicit merchant attributes always win. Ambiguous enum values or values
153
+ too long to represent fail with the product and field rather than guessing.
154
+ - Ask the owner **once, early**, for their return window, eligible items,
155
+ return cost and published policy-page URL. Leave unanswered terms pending;
156
+ never invent a return window, free returns or a return cost. Keep the
157
+ existing policy cost/URL confirmation in `relyon-setup`. Save the confirmed
158
+ policy with `kit.replaceStorePolicies` or `kit.syncStorePolicies`, then
159
+ **sync the catalog again**. The kit reads the saved store policy on sync and
160
+ projects `window_days` (including zero) and `policy_url` into indexed product
161
+ returns only when the product has no explicit returns. Local product URLs,
162
+ feed metadata and options remain unchanged. A failed policy read fails sync
163
+ visibly; it is not treated as an unanswered owner question.
164
+
165
+ ### The product type in TypeScript
166
+
167
+ Type products as `StoreCatalogProduct` (a `StoreProduct` plus `feed` facts),
168
+ both exported by `@relyon/store-kit`. Two fields are optional in the JSON but
169
+ **required by the TypeScript type**:
170
+
171
+ - `configurable: boolean` on every product: `false` for a product sold as
172
+ listed, `true` when the shopper must make choices the app prices.
173
+ - `agent: { visible, purchasable }`, both booleans, whenever `agent` is set
174
+ (and source-backed discovery needs `visible: true`).
175
+
176
+ Money is `{ amount, currency }`: `amount` in integer minor units, `currency`
177
+ an ISO 4217 code in upper case such as `"USD"`.
178
+
179
+ ```ts
180
+ import type { StoreCatalogProduct, StoreCatalogSource } from "@relyon/store-kit";
181
+
182
+ const lavender: StoreCatalogProduct = {
183
+ merchant_product_id: "lavender-candle",
184
+ title: "Lavender candle",
185
+ description: "Hand-poured soy candle with lavender oil. 40-hour burn.",
186
+ url: "https://shop.example.com/products/lavender-candle",
187
+ images: ["https://shop.example.com/images/lavender-candle.jpg"],
188
+ from_price: { amount: 2400, currency: "USD" }, // display only
189
+ availability: "in_stock",
190
+ configurable: false, // sold as listed
191
+ agent: { visible: true, purchasable: true },
192
+ feed: { exactPrice: { amount: 2400, currency: "USD" }, condition: "new" },
193
+ };
194
+
195
+ const giftBox: StoreCatalogProduct = {
196
+ merchant_product_id: "gift-box",
197
+ title: "Candle gift box",
198
+ description: "Three candles in scents the shopper picks.",
199
+ url: "https://shop.example.com/products/gift-box",
200
+ images: ["https://shop.example.com/images/gift-box.jpg"],
201
+ from_price: { amount: 6000, currency: "USD" },
202
+ availability: "in_stock",
203
+ configurable: true, // the shopper picks scents; priceCart prices the choice
204
+ options: { scents: ["lavender", "cedar", "citrus"] },
205
+ agent: { visible: true, purchasable: true },
206
+ };
207
+
208
+ const PRODUCTS = [lavender, giftBox];
209
+
210
+ export const catalogSource: StoreCatalogSource = {
211
+ listProducts: () => ({ products: PRODUCTS, nextCursor: null }),
212
+ getProduct: (id: string) => PRODUCTS.find((product) => product.merchant_product_id === id) ?? null,
213
+ };
214
+ ```
215
+
216
+ The configurable gift box has no `feed.exactPrice`, so feeds leave it out
217
+ (`exact_item_price_required`); agents still find it and pass the choices.
218
+
219
+ ## Source-backed discovery and feeds
220
+
221
+ Configure `catalog.source` with **both** callbacks, as the runnable setup and
222
+ `store.js` example do:
223
+
224
+ - `listProducts({ cursor, limit, query })` returns `{ products, nextCursor }`.
225
+ Return at most `limit` products (the kit requests 500), with stable unique IDs.
226
+ A nonempty, nonrepeating opaque `nextCursor` continues the same ordered query;
227
+ `null` explicitly ends it. Never repeat cursors, duplicate IDs across pages,
228
+ or silently serve a partial catalog. The kit caps traversal at 100 pages.
229
+ - `getProduct(id)` returns the same source-backed product or `null`, never a
230
+ mirror lookup. Both callbacks read the app's durable product data.
231
+ - Explicit `agent: { visible: true }` is required in source mode. Missing or
232
+ false visibility excludes the product from feeds, MCP browse/get, llms and
233
+ sitemap. Product page URLs must be HTTPS on a configured store hostname.
234
+ Source failure fails the read; there is **no index fallback**.
235
+
236
+ The source product extends the ordinary product with `feed` facts:
237
+ `feed.exactPrice: { amount, currency }` is the actual selected item's price,
238
+ in integer minor units; `feed.condition` is verified `new`, `used` or
239
+ `refurbished`. `from_price` stays display only, never an exact feed price.
240
+ For a variant, provide a unique item ID, actual variant price/stock/URL,
241
+ and `feed.variant: { groupId, options: { color: "actual supplier color" } }`.
242
+ Keep group IDs and option keys consistent; XML supports color, size, material
243
+ and pattern. A feed group ID is 1–50 letters, digits, `.`, `_`, `:` or `-`.
244
+ The kit uses a valid `groupId` as it is; a longer one (a long product handle)
245
+ or one with other characters becomes a short readable prefix plus a hash of
246
+ the whole value, the same on every run and in every feed. `feedGroupId(groupId)`
247
+ shows the ID a value becomes. A configurable parent without a selected exact item is omitted.
248
+
249
+ **A product with options, priced per variant.** A product with
250
+ `configurable: true` lists every variant it sells in `feed.variants`, each
251
+ with its own feed `id`, `options` and exact price. Do not flatten options into
252
+ separate products: list one configurable product and its variants. The feeds
253
+ then have one row per variant, all grouped under the product's ID, each with
254
+ its own price, and agents (MCP, test-checkout, cart transfer) buy a variant by
255
+ its feed ID. The example: a Tee, S–XL $25, 2XL–3XL $30, black or white
256
+ (variants over size × colour):
257
+
258
+ ```js
259
+ const SIZES = ["S", "M", "L", "XL", "2XL", "3XL"];
260
+ const COLORS = ["black", "white"];
261
+ const teePrice = size => (size === "2XL" || size === "3XL" ? 3000 : 2500);
262
+ const classicTee = {
263
+ merchant_product_id: "classic-tee",
264
+ title: "Classic Tee",
265
+ description: "Heavyweight cotton tee.",
266
+ url: `${ORIGIN}/products/classic-tee`, // ORIGIN: the store's STORE_PUBLIC_URL
267
+ images: [`${ORIGIN}/img/classic-tee.jpg`],
268
+ brand: "Example Store",
269
+ mpn: "TEE-CLASSIC",
270
+ from_price: { amount: 2500, currency: "USD" }, // display only
271
+ availability: "in_stock",
272
+ configurable: true,
273
+ options: { size: SIZES, color: COLORS },
274
+ agent: { visible: true, purchasable: true },
275
+ feed: {
276
+ condition: "new",
277
+ ownBrand: true,
278
+ variants: SIZES.flatMap(size => COLORS.map(color => ({
279
+ id: `classic-tee-${size.toLowerCase()}-${color}`, // e.g. classic-tee-2xl-white
280
+ options: { size, color },
281
+ exactPrice: { amount: teePrice(size), currency: "USD" }, // amount: 3000 for 2XL and 3XL
282
+ }))),
283
+ },
284
+ };
285
+ ```
286
+
287
+ A variant may also carry its own `availability`, `gtin` or `mpn`. The price is
288
+ still the store's: `priceCart` receives the product ID plus the variant's
289
+ `options` (`{ product_id: "classic-tee", options: { size: "2XL", color: "white" } }`)
290
+ and must charge the same amount for that variant. When an option value is
291
+ wrong, throw a `StoreRefusal` that names the product and the option (for
292
+ example `Product "classic-tee" has no size "4XL"`). Relyon never reads or
293
+ prices options. `npx @relyon/store-kit doctor` warns (product variants, NOT
294
+ DONE) when a product has options but no `feed.variants`, or when options were
295
+ flattened into separate listings with different prices.
296
+
297
+ **POD and dropship stores:** the shared Test defaults apply in Test only.
298
+ Outside those defaults, do not invent brand, GTIN, MPN, condition,
299
+ variant facts or exact prices. Import real supplier facts. Never use the store
300
+ name as a manufacturer by assumption, invent an identifier, or treat a
301
+ display minimum as an exact variant price. Missing required facts may exclude
302
+ a listing; use diagnostics and fix the supplier record instead of fabricating
303
+ values. Google/Microsoft require a valid GTIN or real brand plus MPN.
304
+
305
+ Select files explicitly with `feeds: { formats: [...] }`:
306
+
307
+ | Format option | Store route | Bytes / content type |
308
+ | --- | --- | --- |
309
+ | `openai` | `/feeds/openai.jsonl` | Stable flat OpenAI JSONL, `application/x-ndjson; charset=utf-8` |
310
+ | `openaiGzip` | `/feeds/openai.jsonl.gz` | Gzip of the same JSONL, `application/gzip` |
311
+ | `google` | `/feeds/google.xml` | Google RSS XML, `application/rss+xml; charset=utf-8` |
312
+ | `microsoft` | `/feeds/microsoft.xml` | Common RSS attributes, no Google checkout extensions; same XML content type |
313
+
314
+ Only selected paths are claimed. GET/HEAD and ETag revalidation are supported.
315
+ Internal caching defaults to 60 seconds (`cacheSeconds` 0–300); downstream
316
+ reads must revalidate. Callback failures never serve a stale mirror.
317
+ Use `feeds.onDiagnostic(diagnostic)` to inspect `productId`, `format` and
318
+ `code` without logging customer data. Examples include
319
+ `exact_item_price_required`, `condition_unknown`, `unknown_required_text`
320
+ and `assigned_identifier_missing`. Visibility is necessary but not sufficient
321
+ for a feed listing: format-specific required facts must also pass.
322
+
323
+ To see why a product is missing from a feed, log the diagnostics while you
324
+ build, then fetch the feed again:
325
+
326
+ ```js
327
+ feeds: { formats, onDiagnostic: d => console.warn("feed", d.format, d.productId, d.code) },
328
+ ```
329
+
330
+ The kit's doctor WARNs (never FAILs) when a product in the product sitemap is
331
+ missing from a selected feed, and names the pages.
332
+
333
+ Feed export is **not** destination registration, acceptance, activation or
334
+ agent payment permission. A merchant must separately submit/register the
335
+ destination and obtain its approval. Google checkout facts require an
336
+ explicit connected channel and actual eligibility; never infer those from
337
+ visibility. Merchant restrictions, agent verification and payment limits
338
+ still apply.
339
+
340
+ **When ChatGPT checkout eligibility turns true.** The ChatGPT file
341
+ (`openai`, `openaiGzip`) sets `is_eligible_checkout: true` for a product
342
+ automatically, with no code change, only when all of these hold:
343
+
344
+ 1. Relyon reports the store's ChatGPT channel approved and connected
345
+ (`GET /v1/channels/chatgpt` answers `status: "connected"` in the key's own
346
+ mode). That needs the merchant's ChatGPT application to be approved; the
347
+ kit re-reads it at most once a minute, and a failed read counts as not
348
+ connected.
349
+ 2. The store has `policies.privacyUrl` and `policies.termsUrl`: they become
350
+ the row's `seller_privacy_policy` and `seller_tos`.
351
+ 3. The product is in stock and agents may buy it without asking first
352
+ (`agent.purchasable` not false, no `restrictions`, no `must_ask`).
353
+ 4. The product has the merchant's brand and a valid GTIN or merchant-supplied
354
+ MPN, also included in the synced catalog index. Never invent identifiers.
355
+
356
+ Otherwise the row stays `is_eligible_checkout: false` and, while the channel
357
+ is connected, the feed's diagnostics name the reason
358
+ (`chatgpt_checkout_ineligible:privacy_and_terms_urls_required`, `…:not_in_stock`
359
+ or `…:purchase_restricted`, `…:brand_required`, `…:gtin_or_mpn_required`).
360
+ Never set it by hand.
361
+
362
+ **Select all three feeds** (`["openai", "openaiGzip", "google", "microsoft"]`,
363
+ as the starter does) unless the merchant asks otherwise. Every selected feed
364
+ is advertised in `llms.txt` and by `kit.renderDiscoveryLinks(request)` in the
365
+ homepage `<head>`, and every link in it uses the store's public address. A
366
+ feed with no rows still answers, and `feeds.onDiagnostic` receives a
367
+ `feed_empty` diagnostic whose `missing` list names the product facts that
368
+ kept products out (for example `exact_item_price_required` or
369
+ `assigned_identifier_missing`): fix those in the product data.
370
+
371
+ ## Sync the index: the products agent checkout can buy
372
+
373
+ Store-owned `catalog.source` callbacks need no sync for discovery: the kit
374
+ serves the store's llms.txt, sitemaps and feeds from them. Relyon also keeps an
375
+ index of the store's products. It is a
376
+ mirror for discovery, not the price authority: agents and shoppers are always
377
+ charged what `priceCart` returns at checkout. Agent checkout (store MCP, UCP
378
+ and ACP) only accepts products that are published in this index, so a store
379
+ that takes agent checkouts syncs once a Test key is set (the starter's
380
+ `main.js` does, after `kit.start()`). The index is never a
381
+ prerequisite or fallback for source-backed feeds and discovery.
382
+
383
+ ```js
384
+ import { formatCatalogIssue } from "@relyon/store-kit";
385
+ const result = await kit.syncCatalog(await listProducts()); // mode "upsert" (default)
386
+ for (const row of result.results) {
387
+ for (const issue of row.issues ?? []) console.warn(formatCatalogIssue(row.id, issue));
388
+ }
389
+ ```
390
+
391
+ - `{ mode: "upsert" }` (default) adds and updates products. `{ mode: "full" }`
392
+ also removes indexed products the list no longer has; use it only when the
393
+ list is the store's complete catalog.
394
+ - Batches of up to 500 products are sent for the app. Rejected products are
395
+ reported in `result.results` and left out of discovery.
396
+ - A failed sync throws `CatalogSyncError` and the last good catalog stays
397
+ in place. Sync again after the app's product data changes (on save, or on a
398
+ schedule), and after `kit.start()`.
399
+ - With `catalog.persistence` (see `relyon-setup`) the last good catalog
400
+ survives restarts.
401
+ - Read every sync issue, including warnings on published products. Each line
402
+ names the product, field and message, never an object placeholder. Missing
403
+ category/attributes are agent work. Until the owner confirms returns, the
404
+ doctor says “Waiting on the owner: set your return window”; that is not
405
+ checkout authority or a passing catalog when other blockers remain.
406
+
407
+ ## Product pages, JSON-LD, llms.txt and the sitemap
408
+
409
+ Use the `policies` option and explicit policy replacement described in
410
+ `relyon-setup` for shipping, privacy, terms and contact links. Print-on-demand
411
+ returns use `scope: "defective_only"` with plain-text conditions, never a general
412
+ "N-day free returns" claim. The reporting window and any stated cost apply only
413
+ to defective/damaged items. Local JSON-LD uses `MerchantReturnNotPermitted`
414
+ for ordinary returns, with the defect window in its description, not
415
+ `merchantReturnDays`. `scope: "none"` never advertises a finite return window.
416
+ Do not add unsupported return properties to feeds or protocol profiles.
417
+
418
+ - **Product pages** are the app's own routes, rendered from `getProduct`.
419
+ Add `kit.renderProductJsonLd(product, request)` to the page's HTML: it
420
+ returns a `<script type="application/ld+json">` tag with schema.org
421
+ `Product` data (name, price, currency, availability, brand, `sku`, and
422
+ `gtin` or `mpn` only when the merchant supplied them), escaped for HTML,
423
+ including the kit's configured `policies`. Pass the page's request so its
424
+ URLs and images use the store's public address. `kit.productJsonLd(product, request)`
425
+ returns the object instead.
426
+ - **The homepage product list** carries the same data:
427
+ `kit.renderProductListJsonLd(products, request)` returns one schema.org
428
+ `ItemList` of `Product` entries (up to 100). Put it in the homepage
429
+ `<head>` with `kit.renderDiscoveryLinks(request)`.
430
+ - **Product images** must load from the store's public address after
431
+ publishing. Store image URLs on the store's own hostname (or as paths the
432
+ app serves); the kit moves own-host URLs onto the public address, but it
433
+ can't fix an image the deployed app doesn't serve or one on another
434
+ site that needs a login. The package also exports stand-alone
435
+ `renderProductJsonLd(product, policies?)` and `productJsonLd(product, policies?)`;
436
+ without `policies` they leave the return policy out.
437
+ - **`/llms.txt`** and **`/sitemap-products.xml`** use the same source visibility
438
+ boundary when `catalog.source` is set. `llms.txt` links only the configured
439
+ feeds, not unselected formats. Without a source, the legacy discovery files
440
+ read the published mirror; that mirror is never used for feed export.
441
+ - The root **`/sitemap.xml`** is a urlset of the same product pages.
442
+ - The kit's `/robots.txt` (served by default) lists both sitemaps. An app
443
+ that keeps its own robots.txt (`robots: false`) adds
444
+ `Sitemap: https://shop.example.com/sitemap-products.xml` to it.
445
+ - Report agent visits to product pages with `kit.recordCrawlerVisit` (see
446
+ `relyon-agents`).
447
+
448
+ ## What Relyon does and doesn't do with the catalog
449
+
450
+ - Relyon never prices a cart and never asks the app for a price. The store
451
+ prices every cart with its own `priceCart` and sends the result with the
452
+ payment; Relyon checks that it adds up and charges exactly `totals.total`.
453
+ - Agents see source-backed products through the store's kit routes and
454
+ selected store-owned feeds; the synced index is what agent checkout buys from.
455
+ - If an agent or channel shows a stale `from_price`, the shopper still pays the
456
+ price `priceCart` returns at checkout. Fix source data, then sync.
457
+
458
+ Relyon's doctor `catalog` check measures the index, not source-feed
459
+ readiness. With `catalog.source`, an empty index is not a discovery failure
460
+ once Relyon has observed the store's own discovery, but agent checkout still
461
+ needs the synced products.
462
+ Without `catalog.source`, the check passes once at least one valid, in-stock
463
+ product is published to the index. The kit's doctor checks the sitemap and
464
+ feeds the store itself serves.
465
+
466
+ ## Robots: served by default, conflict-safe
467
+
468
+ The kit serves `/robots.txt` by default: it allows the AI search and shopping
469
+ crawlers and lists the sitemaps. Opt out with `robots: false` in
470
+ `createStoreKit` (the path then passes to the app). A store that already has
471
+ its own robots policy keeps it: pass `robots: { existing }` (below) so the kit
472
+ merges into it. Keep the merchant's existing
473
+ private-path restrictions and crawler policy. `aiRobotsSection({ origin })`
474
+ returns a standalone section for a genuinely new file; do not overwrite an
475
+ existing file with it. For an existing file use
476
+ `mergeAiRobots(existing, { origin: "https://shop.example.com" })`: it returns
477
+ `{ content, changed, conflicts }` and inherits wildcard private-path rules in
478
+ new crawler groups. On **any conflict it returns the original text unchanged**.
479
+ Explicit crawler disallows, discovery/root disallows, unsupported directives
480
+ and unfinished groups require a merchant decision, not an automatic override.
481
+
482
+ To serve the merged file, give the kit the app's original policy:
483
+
484
+ ```js
485
+ const kit = createRelyonKit({
486
+ robots: {
487
+ existing: () => readFile("robots.txt", "utf8"), // import readFile from node:fs/promises
488
+ onConflict: conflicts => console.warn("robots policy needs review", conflicts),
489
+ },
490
+ });
491
+ ```
492
+
493
+ Keep this original file separate from the served result; do not feed the
494
+ merged result back as a new policy. On conflict the route serves original
495
+ content, no-store, with `X-Relyon-Robots-Conflicts`. Express/Hono route it via
496
+ middleware; Next.js needs an `app/robots.txt/route.js` file (or the catch-all
497
+ route). The helpers are exports from `@relyon/store-kit`. Robots rules do not
498
+ grant checkout permissions, do not exempt a crawler from security checks, and never remove
499
+ merchant restrictions.