@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Relyon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/QUICKSTART.md ADDED
@@ -0,0 +1,239 @@
1
+ First read the relyon-setup skill (.agents/skills/relyon-setup/SKILL.md, .claude/skills/relyon-setup/SKILL.md or .cursor/skills/relyon-setup/SKILL.md).
2
+
3
+ # Relyon Core quick start — Test only
4
+
5
+ This guide is only for the optional kit-built shopping pages the user chose.
6
+ For payments only, follow https://core.getrelyon.com/docs/payments-quickstart and the
7
+ relyon-payments skill instead: no kit, catalog or shopping pages.
8
+
9
+ When uncertain about the kit version, run `npm view @relyon/kit version`,
10
+ compare with the actually installed version, and install that exact version with
11
+ the project's package manager. Never downgrade. If the lookup is unavailable, say
12
+ so rather than guessing. Run `npx @relyon/kit doctor` afterward; respect any
13
+ package-age hold without changing settings.
14
+
15
+ Do not read dist files, framework docs, or the full README.
16
+ Six skills are references: open only the section a numbered step names.
17
+
18
+ Domain verification is an agent step, not the owner's: run
19
+ `kit.ensureDomain()` and serve its verification value, then
20
+ `kit.verifyDomain(domain.hostname)` yourself, then re-run the doctor. Only a
21
+ custom domain the owner has not bought yet goes to the owner.
22
+
23
+ ## 1. Init first
24
+
25
+ In the app's project directory:
26
+
27
+ ```sh
28
+ npx @relyon/kit@latest init
29
+ ```
30
+
31
+ Read `relyon/QUICKSTART.md`. Init installs kit `1.0.0` and references.
32
+ Linked skills are in `.agents/skills/` or `.cursor/skills/` (Claude Code:
33
+ `.claude/skills/`); look in both before concluding a skill is missing.
34
+ `init --store "your idea"` saves merchant data, not instructions; `--help` lists
35
+ options. AGENTS.md, CLAUDE.md and replit.md get the Relyon blocks (a pointer and
36
+ a "definition of done") created or appended; other
37
+ conflicts write nothing: compare or preserve edits before `--force`. Never
38
+ bypass symlink/marker refusals.
39
+
40
+ With RELYON_API_KEY in the environment, init uses it and writes no key file.
41
+ Init never creates sandboxes: with no key it prints the get-key URL and
42
+ `init --key-from-stdin`; open that page to get a Test key and run that command
43
+ yourself. The key is saved privately (outside the app and every git tree) and
44
+ init sets `RELYON_API_KEY` in `.env` (0600, gitignored), printing only what
45
+ happened. Never read or print the private key file: that is the merchant's.
46
+ If init fails with a named reason, follow the remedy it prints.
47
+ Example env files: `RELYON_API_KEY=` (blank; `init --key-from-stdin` fills it).
48
+ A placeholder value counts as no key. The `.env` Test key is readable
49
+ by any coding agent in the project, and remixes, forks and exports copy it:
50
+ tell the merchant. `RELYON_AUTO_TEST_KEY=true` and `--auto-test-key` are
51
+ accepted for scripts and change nothing.
52
+
53
+ Plain npm install? Still run init first; scripts/output may be disabled.
54
+ Reproducible dependency: `npm install @relyon/kit@1.0.0`.
55
+ Unpublished validation: install the local tarball, then run
56
+ `./node_modules/.bin/relyon-kit init --skip-install`, never `@latest`.
57
+ Workspaces: follow init's server-package command.
58
+
59
+ ### Test defaults — not merchant policy
60
+
61
+ | Item | Test default |
62
+ | --- | --- |
63
+ | Brand | Store name, unless the merchant supplies another brand. |
64
+ | MPN | SKU, unless the merchant supplies another MPN. |
65
+ | Stock | Available unless told otherwise; no invented inventory count. |
66
+ | Returns/support | Pending merchant items. Never invent them or submit placeholders as real policy data. |
67
+
68
+ Explicit facts override defaults. Ask before asserting missing tax/supplier/
69
+ policy promises or syncing them; block dependent checks, not building.
70
+
71
+ ## 2. Mount kit routes (implementation, not a CLI command)
72
+
73
+ Use Node 20+, ESM, one kit per process, `priceCart`, transactional `createOrder`,
74
+ read-only `findOrderByPaymentId`. Deployed/multiprocess stores need shared durable
75
+ checkout/payment/claim/event storage. Never disable reporting.
76
+ Open setup's [Express wiring](skills/relyon-setup/references/express-server.md)
77
+ and [durable state](skills/relyon-setup/references/durable-state.md).
78
+ [Create kit](skills/relyon-setup/SKILL.md#create-the-kit-on-the-server):
79
+
80
+ ```js
81
+ import { createStoreKit } from "@relyon/kit";
82
+ import { storeKitMiddleware } from "@relyon/kit/express";
83
+ // options: store callbacks, durable adapters, server-only configuration.
84
+ const kit = createStoreKit(options);
85
+ app.use(storeKitMiddleware(kit)); // before body parsing/auth/static/SPA catch-all
86
+ app.use(express.json());
87
+ ```
88
+
89
+ Mount the kit always; it waits safely without a key. Never wrap
90
+ `createStoreKit`/`storeKitMiddleware` in a check on `RELYON_API_KEY`.
91
+ Next.js 15/16 App Router: use setup's
92
+ [App Router reference](skills/relyon-setup/references/next-app-router.md); add no
93
+ `export const runtime`/`dynamic` (Next 16 `cacheComponents` refuses them).
94
+
95
+ Checkout stays on-store: only Relyon's card fields enter the browser.
96
+ Never collect card data in app code/logs or add payment intermediaries.
97
+ Never blindly retry provisioning; preserve keys.
98
+ Plain Node/Express servers don't read `.env`: load the key with
99
+ `const { apiKey, webhookSecret } = await loadTestConfig({ project: process.cwd() })` from
100
+ `@relyon/kit/server-config` (environment, private folder, then `.env`) or
101
+ dotenv. Pass `apiKey` into `relyon.apiKey` and `webhookSecret` into
102
+ `rules.webhookSecret`; restart after the webhook command saves the secret.
103
+ Never cat or print `.env`; never paste the key into a command.
104
+ No key yet? Kit routes answer `waiting_for_sandbox_key`; never a fake key.
105
+ Never request, print, log or commit credentials/claim URLs.
106
+ Restart with a real Test key; resume checks without rebuilding.
107
+
108
+ ## 3. Catalog and discovery
109
+
110
+ Use durable `catalog.source.listProducts({ cursor, limit, query })` →
111
+ `{ products, nextCursor }`, `getProduct(id)` → product or null. Open catalog's
112
+ [source shape](skills/relyon-catalog/SKILL.md#the-product-type-in-typescript)
113
+ and [feeds](skills/relyon-catalog/SKILL.md#source-backed-discovery-and-feeds).
114
+ Use minor units/uppercase currency; `from_price` is display-only.
115
+ Set `configurable`, variants, exact feed prices,
116
+ `agent: { visible: true, purchasable: true }` (not purchase authority).
117
+ Select needed feeds; never invent GTINs/supplier attestations.
118
+ Defaults are not Live facts. Serve product pages/images with
119
+ `kit.renderProductJsonLd(product, request)` and homepage
120
+ `kit.renderDiscoveryLinks(request)`.
121
+ With a key run `await kit.start()` then `kit.syncCatalog(products)` and after edits.
122
+ Source discovery needs no sync.
123
+
124
+ Use agents' [UCP/ACP/MCP routes](skills/relyon-agents/SKILL.md#what-the-kit-serves-on-the-stores-domain).
125
+ The kit serves `/robots.txt` by default (`robots: false` opts out); keep an
126
+ existing policy with the [robots merge](skills/relyon-catalog/SKILL.md#robots-served-by-default-conflict-safe).
127
+ Feed export/discovery is not channel approval or permission to buy.
128
+
129
+ ## 4. Store-owned checkout
130
+
131
+ Required storefront pages: /, /products/<id>, /cart, /checkout and the policy pages. /cart is a real server-rendered or routed page that answers 200, lists the cart's line items (or an empty state) and links to /checkout. A drawer may also exist but does not replace /cart.
132
+
133
+ Use checkout's
134
+ [flow](skills/relyon-checkout/SKILL.md#the-flow) and
135
+ [checkout page](skills/relyon-checkout/references/checkout-page.md).
136
+ Price server-stored carts; show lines/shipping/tax/discounts/total.
137
+ Use server `kit.cardFields(...)`, browser `tokenize()`, then server
138
+ `kit.createPayment(...)` for the unchanged displayed total.
139
+ Use [payment compatibility](skills/relyon-checkout/SKILL.md#createpayment-charge-the-stores-total):
140
+ leave `paymentCartFormat` unset (`server-legacy` is deprecated).
141
+ Use `kit.landing(request)`'s trusted channel, never a browser channel.
142
+ Keep a stable private cart-token secret.
143
+
144
+ Record attempts before sending. Replay the same cart/payment method/order
145
+ reference/Idempotency-Key. Re-price before the first charge, never into a changed
146
+ retry. Lost answers are unknown: disable Pay, confirm that attempt.
147
+ Paid but unsaved means "Your payment went through.
148
+ Your order is still being placed", not completed. Never charge again to recover.
149
+ Keep orders unique on payment ID. Implement every
150
+ [retry safeguard](skills/relyon-checkout/SKILL.md#lost-answers-retries-and-reloads-never-two-charges).
151
+
152
+ ## 5. Publish, then register the webhook
153
+
154
+ Publish the store, then register its webhook endpoint yourself (re-run after
155
+ each publish if the URL changed):
156
+
157
+ ```sh
158
+ npx --no-install @relyon/kit webhook
159
+ ```
160
+
161
+ It registers `$STORE_PUBLIC_URL/relyon/webhooks`, idempotently. Before publishing, add `RELYON_API_KEY` in the host's environment settings.
162
+ With an environment API key, the command (and init's best-effort registration)
163
+ writes no file: the kit resolves the webhook signing secret itself at runtime.
164
+ Only a local file key saves `RELYON_WEBHOOK_SECRET` to gitignored `.env` (0600,
165
+ never printed). `RELYON_WEBHOOK_SECRET` in the environment is an optional explicit
166
+ override. `--rotate` rotates in place and, with an environment key, saves nothing;
167
+ runtime resolution picks up the new secret. If using an explicit override,
168
+ unset or update it in the host's environment settings after rotation. Live works
169
+ the same way once approved: the Live key in the host's environment settings, no
170
+ file. If a Live key leaks: revoke it, then run the webhook command with `--rotate` using the replacement key.
171
+ Details: [webhook setup](skills/relyon-agents/SKILL.md#agent-rules).
172
+
173
+ ## 6. Doctor — inspect actual findings
174
+
175
+ Run it with or without a key. Set the running `STORE_PUBLIC_URL` (loopback allows HTTP/its port):
176
+
177
+ ```sh
178
+ npx --no-install @relyon/kit doctor --url "$STORE_PUBLIC_URL"
179
+ ```
180
+
181
+ Remote: HTTPS, `RELYON_PREVIEW_HOSTS` when needed. Do not publish to reach doctor.
182
+ Read
183
+ [diagnostics](skills/relyon-setup/SKILL.md#diagnose-without-overclaiming)
184
+ Doctor FAILs a kit route answered by the app's catch-all page and a server
185
+ answering 200 for unknown paths, and WARNs on a kit gated on `RELYON_API_KEY`.
186
+ The first line says `DONE` or `NOT DONE`; you are done only at DONE (exit 0;
187
+ 2 NOT DONE, 1 any FAIL). Do the "Do this next" steps in order and rerun. Fix store
188
+ failures; record credential/policy/webhook/channel/runtime blockers verbatim.
189
+ Never invent statuses or deselect required feeds to pass.
190
+ Policy sync needs merchant approval, never a checkout side effect. Test policy
191
+ URLs may be plain http on the loopback host; Live requires https.
192
+ Use [store policies](skills/relyon-setup/SKILL.md#store-policies-explicit-synchronization)
193
+ and [webhook setup](skills/relyon-agents/SKILL.md#agent-rules) when prerequisites
194
+ exist. Handle one-time secrets privately; never sync placeholders.
195
+
196
+ ## 7. Genuine Test purchase
197
+
198
+ You run this; it is not a step for a person. With the server running on its
199
+ Test key:
200
+
201
+ ```sh
202
+ npx --no-install @relyon/kit test-checkout --url "$STORE_PUBLIC_URL"
203
+ ```
204
+
205
+ It buys one product once through the kit's Test-only route (mock processor
206
+ token, no card data, the store's own `priceCart`/`createOrder`), waits for
207
+ Relyon's confirmation, then says to rerun doctor. Refused in Live. If it says
208
+ the Test processor isn't the mock one, buy on the store page instead:
209
+ use checkout's [Test purchases](skills/relyon-checkout/SKILL.md#test-purchases-end-to-end).
210
+ Buy on the store page, never a real card. Mock fields collect no card data;
211
+ processor-backed Test uses that processor's published test cards only.
212
+ Record displayed total, actual `pay_` ID, `livemode: false`, succeeded status
213
+ and exactly one saved order. Reload/retry recovers that payment/order.
214
+ Missing credentials/`processor_not_configured`? Record the blocker, never success.
215
+ Save actual `payment.order_id` (`ord_`) for fulfillment; no ID means no claim.
216
+
217
+ UCP Test checkout is implemented. ACP needs channel setup, ChatGPT credentials,
218
+ application/channel prerequisites, not promised native ChatGPT availability.
219
+ Store-hosted MCP Test hands off to the store page; Live returns
220
+ `protocol_not_available`. Separate Commerce MCP supports
221
+ checkout-link handoff, not direct charging. Relyon verifies agents and enforces
222
+ consent, restrictions and limits; never bypass refusals or change identity.
223
+
224
+ ## 8. Handover and stop in Test
225
+
226
+ Use go-live's [hand-over checklist](skills/relyon-go-live/SKILL.md#hand-over-checklist).
227
+ Give commands/URLs, checks, doctor findings, payment/order evidence or blockers,
228
+ defaults, pending merchant items and checks to resume. Separate discovery,
229
+ purchase and channel approval. Never call unverified checks passed.
230
+ Agents never approve Live or promise approval; after staff approval they activate it only at the merchant's explicit instruction. Retain all security safeguards.
231
+
232
+ ## Need more?
233
+
234
+ | Need | Open only |
235
+ | --- | --- |
236
+ | Reporting | [Agent events](skills/relyon-agents/SKILL.md#agent-activity-reporting-stays-on) |
237
+ | Order recovery | [Paid but unsaved](skills/relyon-orders/SKILL.md#paid-but-the-order-is-not-saved) |
238
+
239
+ Finish with `npx @relyon/kit doctor` and fix every FAIL.
package/README.md CHANGED
@@ -1,3 +1,118 @@
1
- # Temporary Holding Version
1
+ # @relyon/kit
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Relyon for your app, in three layers. Pick the one you need:
4
+
5
+ 1. **Payments**: accept card payments in your own app. No Relyon product catalog or shopping pages.
6
+ 2. **Products and agents**: also list products so AI shopping agents can find and buy them.
7
+ 3. **Shopping pages**: also have Relyon's kit build the shopping pages for you.
8
+
9
+ Each layer includes the ones before it. `@relyon/kit` replaces `@relyon/store-kit`, which still works
10
+ as a thin wrapper around this package.
11
+
12
+ ## Start
13
+
14
+ In the app's project directory:
15
+
16
+ ```sh
17
+ npx @relyon/kit@1.0.0 init
18
+ ```
19
+
20
+ On a terminal, init asks which layer you want. In a script or a coding agent, pass one flag:
21
+ `--payments`, `--products` or `--pages`. Without a flag a non-interactive run refuses and writes
22
+ nothing; it never guesses. The choice is recorded in `relyon/kit.json`.
23
+
24
+ | Layer | init | Prove it with |
25
+ | --- | --- | --- |
26
+ | Payments | `npx @relyon/kit init --payments` | `npx @relyon/kit check` |
27
+ | Products and agents | `npx @relyon/kit init --products` | `npx @relyon/kit doctor` |
28
+ | Shopping pages | `npx @relyon/kit init --pages` (or `--template next\|express`) | `npx @relyon/kit doctor` |
29
+
30
+ The doctor requires a real `/cart` page only for the shopping-pages layer.
31
+
32
+ ## Payments only
33
+
34
+ ```sh
35
+ npx @relyon/kit init --payments # --framework express|next|node to choose the helper's style
36
+ npx @relyon/kit check
37
+ ```
38
+
39
+ Payments mode writes `relyon/payments.ts` (for Express, Next.js or a plain Node server), the
40
+ `relyon-payments` skill when this package carries it, and an agent-instructions block in
41
+ `AGENTS.md` and `CLAUDE.md`. It adds no catalog, product feeds, `/cart` page or store hostnames.
42
+
43
+ The helper serves three routes:
44
+
45
+ - `POST /relyon/payments/session`: a payment session for your checkout page (the hosted card fields'
46
+ client token and script URL), for an order your server already knows;
47
+ - `POST /relyon/payments/charge`: charges the order's amount from your own records with the card
48
+ fields' `tokenize()` result, passed through unchanged;
49
+ - `POST /relyon/webhooks`: Relyon's events, verified against `RELYON_WEBHOOK_SECRET`.
50
+
51
+ Refunds stay server-side: call `refundPayment(paymentId, amount?)` from your own admin code.
52
+
53
+ In code:
54
+
55
+ ```ts
56
+ import { createPayments } from "@relyon/kit/payments";
57
+
58
+ const payments = createPayments(); // RELYON_API_KEY, RELYON_BASE_URL, RELYON_LIVE, RELYON_WEBHOOK_SECRET
59
+ const session = await payments.createSession({ amount: 2500, currency: "USD", orderReference: "order_123" });
60
+ const payment = await payments.charge({ amount: 2500, currency: "USD", orderReference: "order_123", paymentMethod });
61
+ await payments.refund(payment.id, { amount: 500 });
62
+ const verified = payments.verifyWebhook({ rawBody, signature }); // true only for a correctly signed body
63
+ ```
64
+
65
+ Charge only the amount from your own order records, never an amount the browser sends. The kit never
66
+ handles card numbers.
67
+
68
+ ### `npx @relyon/kit check`
69
+
70
+ Four steps, then `DONE`:
71
+
72
+ 1. a Test key is present (`RELYON_API_KEY`, or the one init saved privately);
73
+ 2. Relyon creates a payment session with it;
74
+ 3. a Test charge on Relyon's mock processor succeeds;
75
+ 4. a webhook signature verifies, and a tampered one is refused.
76
+
77
+ Every failing step says what to fix. If the workspace's Test payments use a processor other than
78
+ Relyon's mock, step 3 is reported as not run (never passed): make one Test payment through your own
79
+ checkout page, or switch the Test processor to the mock. Key values are never printed. `check` runs
80
+ in Test only.
81
+
82
+ ## Products, agents and shopping pages
83
+
84
+ ```ts
85
+ import { createKit } from "@relyon/kit";
86
+
87
+ const kit = createKit({
88
+ projectSpace: { name: "Example Shop", hostnames: ["shop.example.com"] }, // publicUrl defaults to PUBLIC_URL
89
+ priceCart,
90
+ createOrder,
91
+ });
92
+ ```
93
+
94
+ `createStoreKit`, `StoreKitOptions` and the `store` option still work. Framework adapters:
95
+ `@relyon/kit/express`, `@relyon/kit/next` and `@relyon/kit/hono`; server configuration:
96
+ `@relyon/kit/server-config`. Layer entry points: `@relyon/kit/payments`, `@relyon/kit/products`
97
+ and `@relyon/kit/pages`.
98
+
99
+ ## Environment
100
+
101
+ | Variable | Meaning |
102
+ | --- | --- |
103
+ | `RELYON_API_KEY` | The secret key, on the server only. Test keys start `rly_test_`. |
104
+ | `RELYON_LIVE` | `true` switches Live on explicitly; a Live key alone is refused. |
105
+ | `PUBLIC_URL` | The app's public origin (`STORE_PUBLIC_URL` is still accepted). |
106
+ | `RELYON_PROJECT_SPACE` | The project space's ID; optional in a single-space workspace. |
107
+ | `RELYON_WEBHOOK_SECRET` | The webhook endpoint's signing secret. |
108
+
109
+ Never print `.env` or paste a key into a command or chat.
110
+
111
+ ## Moving from @relyon/store-kit
112
+
113
+ Replace the dependency with `@relyon/kit@1.0.0` and change imports from `@relyon/store-kit` to
114
+ `@relyon/kit` (same subpaths). Commands are the same: `npx @relyon/kit init`, `doctor`,
115
+ `test-checkout` and `webhook`. Existing apps keep working on `@relyon/store-kit`, whose commands
116
+ print a one-line notice pointing here.
117
+
118
+ See `CHANGELOG.md` for what changed. License: MIT.
@@ -0,0 +1,39 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import type { RequestInfo } from "../types.js";
3
+ /** What the adapter mounts: the kit, or the payments-only routes. */
4
+ export interface FetchRoutes {
5
+ matches(pathname: string): boolean;
6
+ readonly maxBodyBytes: number;
7
+ handle(request: Request, info?: RequestInfo): Promise<Response | null>;
8
+ }
9
+ /** The parts of an Express (4 or 5) request the adapter reads. No runtime dependency on Express. */
10
+ type ExpressRequest = IncomingMessage & {
11
+ originalUrl?: string | undefined;
12
+ protocol?: string | undefined;
13
+ ip?: string | undefined;
14
+ body?: unknown;
15
+ };
16
+ type Next = (error?: unknown) => void;
17
+ /**
18
+ * Express middleware serving the kit's routes. Mount it before any body
19
+ * parser (or at least before parsers that see the kit's paths): the kit needs
20
+ * the raw body, exactly as the agent sent it, to relay signed requests.
21
+ */
22
+ export declare function storeKitMiddleware(kit: FetchRoutes): (req: ExpressRequest, res: ServerResponse, next: Next) => Promise<void>;
23
+ /** Writes a Web Response onto a Node response. */
24
+ export declare function writeResponse(res: ServerResponse, response: Response): Promise<void>;
25
+ /** `storeKitMiddleware` under the kit's name. */
26
+ export declare const kitMiddleware: typeof storeKitMiddleware;
27
+ /**
28
+ * Express middleware for the payments-only routes (`createPaymentRoutes`):
29
+ * `app.use(paymentsMiddleware(routes))`, before express.json().
30
+ */
31
+ export declare const paymentsMiddleware: (routes: FetchRoutes) => (req: ExpressRequest, res: ServerResponse, next: Next) => Promise<void>;
32
+ /**
33
+ * A plain Node server's handler for the same routes: resolves true when it
34
+ * answered, false when the app's own routes should.
35
+ *
36
+ * createServer(async (req, res) => { if (await handle(req, res)) return; ... })
37
+ */
38
+ export declare function paymentsNodeHandler(routes: FetchRoutes): (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
39
+ export {};
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Express middleware serving the kit's routes. Mount it before any body
3
+ * parser (or at least before parsers that see the kit's paths): the kit needs
4
+ * the raw body, exactly as the agent sent it, to relay signed requests.
5
+ */
6
+ export function storeKitMiddleware(kit) {
7
+ return async function relyonStoreKit(req, res, next) {
8
+ try {
9
+ const target = req.originalUrl ?? req.url ?? "/";
10
+ const pathname = new URL(target, "http://localhost").pathname;
11
+ if (!kit.matches(pathname))
12
+ return next();
13
+ if (req.body !== undefined && !Buffer.isBuffer(req.body) && typeof req.body !== "string") {
14
+ throw new Error("A body parser ran before the Relyon store kit. Mount storeKitMiddleware before express.json() so it gets the raw body.");
15
+ }
16
+ const headers = new Headers();
17
+ for (let index = 0; index < req.rawHeaders.length; index += 2)
18
+ headers.append(req.rawHeaders[index], req.rawHeaders[index + 1]);
19
+ const method = (req.method ?? "GET").toUpperCase();
20
+ let body;
21
+ if (method !== "GET" && method !== "HEAD") {
22
+ if (Buffer.isBuffer(req.body))
23
+ body = req.body;
24
+ else if (typeof req.body === "string")
25
+ body = Buffer.from(req.body);
26
+ else
27
+ body = await readAll(req, kit.maxBodyBytes);
28
+ }
29
+ const host = req.headers.host ?? "localhost";
30
+ const request = new Request(`${req.protocol ?? "http"}://${host}${target}`, {
31
+ method, headers, ...(body && body.byteLength > 0 ? { body: body } : {}),
32
+ });
33
+ const response = await kit.handle(request, { ...(req.ip ?? req.socket.remoteAddress ? { ip: req.ip ?? req.socket.remoteAddress } : {}) });
34
+ if (!response)
35
+ return next();
36
+ await writeResponse(res, response);
37
+ }
38
+ catch (error) {
39
+ if (error instanceof TooLarge) {
40
+ res.statusCode = 413;
41
+ res.setHeader("content-type", "text/plain; charset=utf-8");
42
+ res.end("The request body is too large.\n");
43
+ return;
44
+ }
45
+ next(error);
46
+ }
47
+ };
48
+ }
49
+ class TooLarge extends Error {
50
+ }
51
+ function readAll(req, limit) {
52
+ return new Promise((resolve, reject) => {
53
+ const chunks = [];
54
+ let size = 0;
55
+ req.on("data", (chunk) => {
56
+ size += chunk.length;
57
+ if (size > limit) {
58
+ req.removeAllListeners("data");
59
+ req.resume();
60
+ reject(new TooLarge());
61
+ return;
62
+ }
63
+ chunks.push(chunk);
64
+ });
65
+ req.on("end", () => resolve(Buffer.concat(chunks)));
66
+ req.on("error", reject);
67
+ });
68
+ }
69
+ /** Writes a Web Response onto a Node response. */
70
+ export async function writeResponse(res, response) {
71
+ res.statusCode = response.status;
72
+ const cookies = response.headers.getSetCookie?.() ?? [];
73
+ response.headers.forEach((value, name) => {
74
+ if (name.toLowerCase() !== "set-cookie")
75
+ res.setHeader(name, value);
76
+ });
77
+ if (cookies.length)
78
+ res.setHeader("set-cookie", cookies);
79
+ const body = response.body ? Buffer.from(await response.arrayBuffer()) : undefined;
80
+ res.end(body);
81
+ }
82
+ /** `storeKitMiddleware` under the kit's name. */
83
+ export const kitMiddleware = storeKitMiddleware;
84
+ /**
85
+ * Express middleware for the payments-only routes (`createPaymentRoutes`):
86
+ * `app.use(paymentsMiddleware(routes))`, before express.json().
87
+ */
88
+ export const paymentsMiddleware = (routes) => storeKitMiddleware(routes);
89
+ /**
90
+ * A plain Node server's handler for the same routes: resolves true when it
91
+ * answered, false when the app's own routes should.
92
+ *
93
+ * createServer(async (req, res) => { if (await handle(req, res)) return; ... })
94
+ */
95
+ export function paymentsNodeHandler(routes) {
96
+ const middleware = storeKitMiddleware(routes);
97
+ return (req, res) => new Promise((resolve, reject) => {
98
+ let passed = false;
99
+ middleware(req, res, (error) => { passed = true; if (error)
100
+ reject(error);
101
+ else
102
+ resolve(false); })
103
+ .then(() => { if (!passed)
104
+ resolve(true); }, reject);
105
+ });
106
+ }
@@ -0,0 +1,16 @@
1
+ import type { FetchRoutes } from "./express.js";
2
+ /** The parts of a Hono context the adapter reads. No runtime dependency on Hono. */
3
+ interface HonoLikeContext {
4
+ req: {
5
+ raw: Request;
6
+ header(name: string): string | undefined;
7
+ };
8
+ }
9
+ /**
10
+ * Hono middleware serving the kit's routes: `app.use(storeKitMiddleware(kit))`.
11
+ * Anything the kit doesn't serve goes on to the store's own routes.
12
+ */
13
+ export declare function storeKitMiddleware(kit: FetchRoutes): (c: HonoLikeContext, next: () => Promise<void>) => Promise<Response | void>;
14
+ /** `storeKitMiddleware` under the kit's name. */
15
+ export declare const kitMiddleware: typeof storeKitMiddleware;
16
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Hono middleware serving the kit's routes: `app.use(storeKitMiddleware(kit))`.
3
+ * Anything the kit doesn't serve goes on to the store's own routes.
4
+ */
5
+ export function storeKitMiddleware(kit) {
6
+ return async (c, next) => {
7
+ const forwarded = c.req.header("x-forwarded-for")?.split(",")[0]?.trim();
8
+ const response = await kit.handle(c.req.raw, forwarded ? { ip: forwarded } : {});
9
+ if (response)
10
+ return response;
11
+ await next();
12
+ };
13
+ }
14
+ /** `storeKitMiddleware` under the kit's name. */
15
+ export const kitMiddleware = storeKitMiddleware;
@@ -0,0 +1,29 @@
1
+ import type { FetchRoutes } from "./express.js";
2
+ type RouteHandler = (request: Request) => Promise<Response>;
3
+ /**
4
+ * Next.js App Router route handlers. Put them in a catch-all route for each
5
+ * kit path, for example `app/ucp/[...path]/route.ts`:
6
+ *
7
+ * export const { GET, POST, PUT, DELETE, HEAD } = storeKitRouteHandlers(kit);
8
+ *
9
+ * Also add routes for `/.well-known/ucp`, `/.well-known/relyon-verification`,
10
+ * `/acp/[...path]`, `/mcp`, `/llms.txt`, the sitemap and the webhook path.
11
+ * No runtime dependency on Next.
12
+ */
13
+ export declare function storeKitRouteHandlers(kit: FetchRoutes): Record<"GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD", RouteHandler>;
14
+ /**
15
+ * The same as one function, for a Next.js middleware (or any Fetch runtime):
16
+ * returns the kit's response, or null to let the store's own routes answer.
17
+ */
18
+ export declare function storeKitFetch(kit: FetchRoutes): (request: Request) => Promise<Response | null>;
19
+ /** `storeKitRouteHandlers` under the kit's name. */
20
+ export declare const kitRouteHandlers: typeof storeKitRouteHandlers;
21
+ /** `storeKitFetch` under the kit's name. */
22
+ export declare const kitFetch: typeof storeKitFetch;
23
+ /**
24
+ * Next.js App Router handlers for the payments-only routes
25
+ * (`createPaymentRoutes`), in one catch-all route such as
26
+ * `app/relyon/[...path]/route.ts`: `export const { POST } = paymentsRouteHandlers(routes);`
27
+ */
28
+ export declare const paymentsRouteHandlers: (routes: FetchRoutes) => Record<"GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD", RouteHandler>;
29
+ export {};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Next.js App Router route handlers. Put them in a catch-all route for each
3
+ * kit path, for example `app/ucp/[...path]/route.ts`:
4
+ *
5
+ * export const { GET, POST, PUT, DELETE, HEAD } = storeKitRouteHandlers(kit);
6
+ *
7
+ * Also add routes for `/.well-known/ucp`, `/.well-known/relyon-verification`,
8
+ * `/acp/[...path]`, `/mcp`, `/llms.txt`, the sitemap and the webhook path.
9
+ * No runtime dependency on Next.
10
+ */
11
+ export function storeKitRouteHandlers(kit) {
12
+ const handler = async (request) => {
13
+ const forwarded = request.headers.get("x-forwarded-for")?.split(",")[0]?.trim();
14
+ const response = await kit.handle(request, forwarded ? { ip: forwarded } : {});
15
+ return response ?? new Response("Not found\n", { status: 404, headers: { "content-type": "text/plain; charset=utf-8" } });
16
+ };
17
+ return { GET: handler, POST: handler, PUT: handler, PATCH: handler, DELETE: handler, HEAD: handler };
18
+ }
19
+ /**
20
+ * The same as one function, for a Next.js middleware (or any Fetch runtime):
21
+ * returns the kit's response, or null to let the store's own routes answer.
22
+ */
23
+ export function storeKitFetch(kit) {
24
+ return (request) => {
25
+ const forwarded = request.headers.get("x-forwarded-for")?.split(",")[0]?.trim();
26
+ return kit.handle(request, forwarded ? { ip: forwarded } : {});
27
+ };
28
+ }
29
+ /** `storeKitRouteHandlers` under the kit's name. */
30
+ export const kitRouteHandlers = storeKitRouteHandlers;
31
+ /** `storeKitFetch` under the kit's name. */
32
+ export const kitFetch = storeKitFetch;
33
+ /**
34
+ * Next.js App Router handlers for the payments-only routes
35
+ * (`createPaymentRoutes`), in one catch-all route such as
36
+ * `app/relyon/[...path]/route.ts`: `export const { POST } = paymentsRouteHandlers(routes);`
37
+ */
38
+ export const paymentsRouteHandlers = (routes) => storeKitRouteHandlers(routes);
@@ -0,0 +1,14 @@
1
+ import type { KitPaths } from "./context.js";
2
+ import type { StoreInfo } from "./discovery.js";
3
+ /** The AP2 extension URI agent cards declare (AP2 v0.1). */
4
+ export declare const AP2_EXTENSION_URI = "https://github.com/google-agentic-commerce/ap2/tree/v0.1";
5
+ export interface AgentCardInput {
6
+ store: StoreInfo;
7
+ /** The store's public address for this request. */
8
+ origin: string;
9
+ paths: Pick<KitPaths, "ucp" | "acp" | "mcp" | "llmsTxt" | "sitemap" | "checkout">;
10
+ livemode: boolean;
11
+ /** The feed URLs the store serves. */
12
+ feedUrls?: readonly string[];
13
+ }
14
+ export declare function agentCard(input: AgentCardInput): Record<string, unknown>;