@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.
- package/AGENTS.md +75 -0
- package/CHANGELOG.md +1053 -0
- package/LICENSE +21 -0
- package/QUICKSTART.md +239 -0
- package/README.md +117 -2
- package/dist/adapters/express.d.ts +39 -0
- package/dist/adapters/express.js +106 -0
- package/dist/adapters/hono.d.ts +16 -0
- package/dist/adapters/hono.js +15 -0
- package/dist/adapters/next.d.ts +29 -0
- package/dist/adapters/next.js +38 -0
- package/dist/agent-card.d.ts +14 -0
- package/dist/agent-card.js +58 -0
- package/dist/agent-docs.d.ts +36 -0
- package/dist/agent-docs.js +78 -0
- package/dist/agent-hooks.d.ts +66 -0
- package/dist/agent-hooks.js +280 -0
- package/dist/agents.d.ts +24 -0
- package/dist/agents.js +120 -0
- package/dist/api-key.d.ts +6 -0
- package/dist/api-key.js +33 -0
- package/dist/cache.d.ts +46 -0
- package/dist/cache.js +86 -0
- package/dist/cart-tokens.d.ts +31 -0
- package/dist/cart-tokens.js +58 -0
- package/dist/cart-transfer.d.ts +95 -0
- package/dist/cart-transfer.js +387 -0
- package/dist/catalog-enrichment.d.ts +6 -0
- package/dist/catalog-enrichment.js +71 -0
- package/dist/catalog-reads.d.ts +126 -0
- package/dist/catalog-reads.js +104 -0
- package/dist/catalog.d.ts +78 -0
- package/dist/catalog.js +288 -0
- package/dist/charge-claims.d.ts +11 -0
- package/dist/charge-claims.js +47 -0
- package/dist/check.d.ts +44 -0
- package/dist/check.js +152 -0
- package/dist/checklist-manifest.d.ts +72 -0
- package/dist/checklist-manifest.js +341 -0
- package/dist/checkout.d.ts +222 -0
- package/dist/checkout.js +353 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +727 -0
- package/dist/confirmation.d.ts +78 -0
- package/dist/confirmation.js +124 -0
- package/dist/context.d.ts +81 -0
- package/dist/context.js +10 -0
- package/dist/discovery.d.ts +151 -0
- package/dist/discovery.js +346 -0
- package/dist/doctor-cart-transfer.d.ts +33 -0
- package/dist/doctor-cart-transfer.js +186 -0
- package/dist/doctor-catalog.d.ts +8 -0
- package/dist/doctor-catalog.js +47 -0
- package/dist/doctor-evidence.d.ts +22 -0
- package/dist/doctor-evidence.js +57 -0
- package/dist/doctor-merchant.d.ts +48 -0
- package/dist/doctor-merchant.js +74 -0
- package/dist/doctor-source.d.ts +5 -0
- package/dist/doctor-source.js +142 -0
- package/dist/doctor-variants.d.ts +70 -0
- package/dist/doctor-variants.js +102 -0
- package/dist/doctor.d.ts +215 -0
- package/dist/doctor.js +1689 -0
- package/dist/events.d.ts +95 -0
- package/dist/events.js +200 -0
- package/dist/feed-mapping.d.ts +114 -0
- package/dist/feed-mapping.js +152 -0
- package/dist/feed-values.d.ts +13 -0
- package/dist/feed-values.js +40 -0
- package/dist/feeds.d.ts +104 -0
- package/dist/feeds.js +366 -0
- package/dist/identify.d.ts +102 -0
- package/dist/identify.js +124 -0
- package/dist/identity.d.ts +37 -0
- package/dist/identity.js +54 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +41 -0
- package/dist/init.d.ts +157 -0
- package/dist/init.js +912 -0
- package/dist/kit-config.d.ts +19 -0
- package/dist/kit-config.js +43 -0
- package/dist/kit-environment.d.ts +20 -0
- package/dist/kit-environment.js +32 -0
- package/dist/kit-updates.d.ts +47 -0
- package/dist/kit-updates.js +77 -0
- package/dist/kit-version-project.d.ts +18 -0
- package/dist/kit-version-project.js +214 -0
- package/dist/kit-version.d.ts +37 -0
- package/dist/kit-version.js +162 -0
- package/dist/kit.d.ts +516 -0
- package/dist/kit.js +1309 -0
- package/dist/layers/pages.d.ts +3 -0
- package/dist/layers/pages.js +5 -0
- package/dist/layers/payments.d.ts +7 -0
- package/dist/layers/payments.js +9 -0
- package/dist/layers/products.d.ts +10 -0
- package/dist/layers/products.js +13 -0
- package/dist/live.d.ts +13 -0
- package/dist/live.js +52 -0
- package/dist/mcp.d.ts +270 -0
- package/dist/mcp.js +312 -0
- package/dist/next-steps.d.ts +101 -0
- package/dist/next-steps.js +257 -0
- package/dist/order-pending.d.ts +57 -0
- package/dist/order-pending.js +127 -0
- package/dist/orders.d.ts +12 -0
- package/dist/orders.js +21 -0
- package/dist/payments-init.d.ts +19 -0
- package/dist/payments-init.js +70 -0
- package/dist/payments-routes.d.ts +54 -0
- package/dist/payments-routes.js +123 -0
- package/dist/payments.d.ts +165 -0
- package/dist/payments.js +192 -0
- package/dist/pnpm-workspace.d.ts +58 -0
- package/dist/pnpm-workspace.js +250 -0
- package/dist/policies.d.ts +111 -0
- package/dist/policies.js +317 -0
- package/dist/preview-hosts.d.ts +64 -0
- package/dist/preview-hosts.js +175 -0
- package/dist/private-config.d.ts +169 -0
- package/dist/private-config.js +820 -0
- package/dist/progress.d.ts +54 -0
- package/dist/progress.js +153 -0
- package/dist/protocol-inputs.d.ts +22 -0
- package/dist/protocol-inputs.js +151 -0
- package/dist/public-origin.d.ts +50 -0
- package/dist/public-origin.js +180 -0
- package/dist/refusals.d.ts +86 -0
- package/dist/refusals.js +157 -0
- package/dist/relay.d.ts +107 -0
- package/dist/relay.js +655 -0
- package/dist/release-notes.d.ts +2 -0
- package/dist/release-notes.js +290 -0
- package/dist/relyon-cart-tokens.d.ts +101 -0
- package/dist/relyon-cart-tokens.js +521 -0
- package/dist/relyon.d.ts +141 -0
- package/dist/relyon.js +238 -0
- package/dist/robots.d.ts +27 -0
- package/dist/robots.js +127 -0
- package/dist/rules.d.ts +144 -0
- package/dist/rules.js +347 -0
- package/dist/sdk/generated/public-api.d.ts +4816 -0
- package/dist/sdk/generated/public-api.js +1 -0
- package/dist/sdk/index.d.ts +24 -0
- package/dist/sdk/index.js +34 -0
- package/dist/sdk/signatures.d.ts +17 -0
- package/dist/sdk/signatures.js +33 -0
- package/dist/setup.d.ts +37 -0
- package/dist/setup.js +94 -0
- package/dist/signatures.d.ts +112 -0
- package/dist/signatures.js +443 -0
- package/dist/state.d.ts +185 -0
- package/dist/state.js +96 -0
- package/dist/store-payments.d.ts +48 -0
- package/dist/store-payments.js +143 -0
- package/dist/structured-fields.d.ts +26 -0
- package/dist/structured-fields.js +200 -0
- package/dist/templates.d.ts +19 -0
- package/dist/templates.js +193 -0
- package/dist/test-checkout-command.d.ts +32 -0
- package/dist/test-checkout-command.js +161 -0
- package/dist/test-checkout.d.ts +88 -0
- package/dist/test-checkout.js +292 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.js +18 -0
- package/dist/ucp-versions.d.ts +57 -0
- package/dist/ucp-versions.js +129 -0
- package/dist/util.d.ts +23 -0
- package/dist/util.js +68 -0
- package/dist/variants.d.ts +67 -0
- package/dist/variants.js +146 -0
- package/dist/version.d.ts +9 -0
- package/dist/version.js +10 -0
- package/dist/waiting.d.ts +43 -0
- package/dist/waiting.js +57 -0
- package/dist/webhook-command.d.ts +48 -0
- package/dist/webhook-command.js +367 -0
- package/dist/webhook-registration.d.ts +47 -0
- package/dist/webhook-registration.js +69 -0
- package/dist/webmcp-schema.d.ts +14 -0
- package/dist/webmcp-schema.js +140 -0
- package/dist/webmcp-script.d.ts +3 -0
- package/dist/webmcp-script.js +176 -0
- package/dist/webmcp-store.d.ts +102 -0
- package/dist/webmcp-store.js +116 -0
- package/dist/webmcp.d.ts +242 -0
- package/dist/webmcp.js +866 -0
- package/dist/wire-names.d.ts +85 -0
- package/dist/wire-names.js +109 -0
- package/package.json +118 -4
- package/release-notes.json +290 -0
- package/scripts/install-notice.cjs +7 -0
- package/skills/relyon-agents/SKILL.md +327 -0
- package/skills/relyon-catalog/SKILL.md +499 -0
- package/skills/relyon-catalog/references/example-store.md +218 -0
- package/skills/relyon-checkout/SKILL.md +603 -0
- package/skills/relyon-checkout/references/checkout-flow.md +257 -0
- package/skills/relyon-checkout/references/checkout-page.md +315 -0
- package/skills/relyon-go-live/SKILL.md +344 -0
- package/skills/relyon-orders/SKILL.md +191 -0
- package/skills/relyon-orders/references/webhook-receiver.md +113 -0
- package/skills/relyon-payments/SKILL.md +117 -0
- package/skills/relyon-setup/SKILL.md +1061 -0
- package/skills/relyon-setup/references/QUICKSTART.md +239 -0
- package/skills/relyon-setup/references/durable-state.md +209 -0
- package/skills/relyon-setup/references/express-server.md +388 -0
- package/skills/relyon-setup/references/next-app-router.md +251 -0
- package/templates/common/STORE-README.md +67 -0
- package/templates/common/gitignore +8 -0
- package/templates/common/scripts/check-pricing.ts +22 -0
- package/templates/common/scripts/serve.mjs +13 -0
- package/templates/common/server/catalog.ts +79 -0
- package/templates/common/server/checkout-flow.d.ts +34 -0
- package/templates/common/server/pages.ts +184 -0
- package/templates/common/server/storage.ts +114 -0
- package/templates/common/server/store.ts +67 -0
- package/templates/express/server/express.ts +20 -0
- package/templates/express/tsconfig.build.json +6 -0
- package/templates/express/tsconfig.json +9 -0
- package/templates/next/app/[[...path]]/route.ts +24 -0
- package/templates/next/next.config.mjs +19 -0
- package/templates/next/tsconfig.json +12 -0
- package/templates/payments/express.ts +39 -0
- package/templates/payments/next.ts +38 -0
- package/templates/payments/node.ts +39 -0
|
@@ -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/store-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/store-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/store-kit@latest init
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Read `relyon/QUICKSTART.md`. Init installs kit `0.1.52` 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/store-kit@0.1.52`.
|
|
55
|
+
Unpublished validation: install the local tarball, then run
|
|
56
|
+
`./node_modules/.bin/store-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](../../relyon-setup/references/express-server.md)
|
|
77
|
+
and [durable state](../../relyon-setup/references/durable-state.md).
|
|
78
|
+
[Create kit](../../relyon-setup/SKILL.md#create-the-kit-on-the-server):
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
import { createStoreKit } from "@relyon/store-kit";
|
|
82
|
+
import { storeKitMiddleware } from "@relyon/store-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](../../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/store-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](../../relyon-catalog/SKILL.md#the-product-type-in-typescript)
|
|
113
|
+
and [feeds](../../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](../../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](../../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](../../relyon-checkout/SKILL.md#the-flow) and
|
|
135
|
+
[checkout page](../../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](../../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](../../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/store-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](../../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/store-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](../../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](../../relyon-setup/SKILL.md#store-policies-explicit-synchronization)
|
|
193
|
+
and [webhook setup](../../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/store-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](../../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](../../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](../../relyon-agents/SKILL.md#agent-activity-reporting-stays-on) |
|
|
237
|
+
| Order recovery | [Paid but unsaved](../../relyon-orders/SKILL.md#paid-but-the-order-is-not-saved) |
|
|
238
|
+
|
|
239
|
+
Finish with `npx @relyon/store-kit doctor` and fix every FAIL.
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Durable state for production
|
|
2
|
+
|
|
3
|
+
The kit's defaults keep everything in one process's memory. In production, and
|
|
4
|
+
whenever the app runs more than one server process, give the kit shared,
|
|
5
|
+
durable stores. This example uses Postgres through any client with
|
|
6
|
+
`query(text, params)` returning `{ rows, rowCount }` (a `pg` `Pool` works).
|
|
7
|
+
Adapt the SQL to the app's own database; keep the guarantees:
|
|
8
|
+
|
|
9
|
+
- `claimOrder` is a single atomic statement. Exactly one caller at a time gets
|
|
10
|
+
`true` for a payment ID, across every process, so `createOrder` runs once per
|
|
11
|
+
payment. A claim holds for the kit's lease (`orderClaimLeaseMs`, default 2
|
|
12
|
+
minutes): a claim that was never marked created may be taken over once its
|
|
13
|
+
lease has passed, because the server that held it may have died while creating
|
|
14
|
+
the order. A claim marked created never expires.
|
|
15
|
+
- `completeOrder` marks the claim created after `createOrder` returned.
|
|
16
|
+
- `releaseOrder` deletes the claim after `createOrder` threw, only while that
|
|
17
|
+
attempt (`claimId`) still holds it, so a retry can create the order.
|
|
18
|
+
- `orderClaimStatus` answers `"created"`, `"creating"` (an unexpired claim) or
|
|
19
|
+
`null`, so the kit can tell an order another request is creating from one that
|
|
20
|
+
exists. Implement all four; without the last two, claims never expire and
|
|
21
|
+
checkouts can stay order pending (see `store-kit-reference.md`, "Production
|
|
22
|
+
stores").
|
|
23
|
+
- Agent events are kept until Relyon accepted them (`remove` is called only
|
|
24
|
+
then), in the order they were appended, and duplicates by `id` are ignored.
|
|
25
|
+
Never make `append` a no-op or cap the table to zero rows; reporting must
|
|
26
|
+
stay on.
|
|
27
|
+
- The catalog store keeps the last good catalog the kit published.
|
|
28
|
+
- Payment records (`getStorePayment`/`putStorePayment`) and hand-off token
|
|
29
|
+
claims (`claimHandoffToken`) are optional members of the same store; the
|
|
30
|
+
`relyon-checkout` skill has a typed version with all of them and the two
|
|
31
|
+
extra tables. Add them before running more than one server process.
|
|
32
|
+
- `postgresStoreCheckouts` holds the app's own checkouts for
|
|
33
|
+
`checkout-flow.js` (`relyon-checkout`). Its `update` is one conditional
|
|
34
|
+
statement, so only one request sends a payment attempt and a checkout is
|
|
35
|
+
never closed while its payment may have gone through.
|
|
36
|
+
|
|
37
|
+
```js durable-state.js
|
|
38
|
+
// Postgres-backed stores for @relyon/store-kit. Run SCHEMA once (a migration).
|
|
39
|
+
export const SCHEMA = `
|
|
40
|
+
create table if not exists relyon_checkouts (
|
|
41
|
+
protocol text not null,
|
|
42
|
+
session_id text not null,
|
|
43
|
+
agent_checkout_id text,
|
|
44
|
+
record jsonb not null,
|
|
45
|
+
updated_at bigint not null,
|
|
46
|
+
primary key (protocol, session_id)
|
|
47
|
+
);
|
|
48
|
+
create index if not exists relyon_checkouts_agent on relyon_checkouts (agent_checkout_id);
|
|
49
|
+
create table if not exists relyon_order_claims (
|
|
50
|
+
payment_id text primary key,
|
|
51
|
+
claim_id text,
|
|
52
|
+
created boolean not null default false,
|
|
53
|
+
expires_at bigint -- the kit's clock (ms); null once created
|
|
54
|
+
);
|
|
55
|
+
create table if not exists relyon_agent_events (
|
|
56
|
+
seq bigserial primary key,
|
|
57
|
+
id text not null unique,
|
|
58
|
+
event jsonb not null
|
|
59
|
+
);
|
|
60
|
+
create table if not exists relyon_catalog (
|
|
61
|
+
singleton boolean primary key default true check (singleton),
|
|
62
|
+
products jsonb not null
|
|
63
|
+
);
|
|
64
|
+
create table if not exists store_checkouts (
|
|
65
|
+
order_reference text primary key,
|
|
66
|
+
state text not null,
|
|
67
|
+
record jsonb not null,
|
|
68
|
+
updated_at timestamptz not null default now()
|
|
69
|
+
);
|
|
70
|
+
create index if not exists store_checkouts_confirming on store_checkouts (updated_at) where state = 'confirming';
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
/** CheckoutStateStore: per-checkout memory and the exactly-once order claim. */
|
|
74
|
+
export function postgresCheckoutState(db) {
|
|
75
|
+
return {
|
|
76
|
+
async get(protocol, sessionId) {
|
|
77
|
+
const { rows } = await db.query(
|
|
78
|
+
"select record from relyon_checkouts where protocol = $1 and session_id = $2", [protocol, sessionId]);
|
|
79
|
+
return rows[0]?.record ?? null;
|
|
80
|
+
},
|
|
81
|
+
async byAgentCheckoutId(agentCheckoutId) {
|
|
82
|
+
const { rows } = await db.query(
|
|
83
|
+
"select record from relyon_checkouts where agent_checkout_id = $1 order by updated_at desc limit 1", [agentCheckoutId]);
|
|
84
|
+
return rows[0]?.record ?? null;
|
|
85
|
+
},
|
|
86
|
+
async put(record) {
|
|
87
|
+
await db.query(
|
|
88
|
+
`insert into relyon_checkouts (protocol, session_id, agent_checkout_id, record, updated_at)
|
|
89
|
+
values ($1, $2, $3, $4, $5)
|
|
90
|
+
on conflict (protocol, session_id) do update
|
|
91
|
+
set agent_checkout_id = excluded.agent_checkout_id, record = excluded.record, updated_at = excluded.updated_at`,
|
|
92
|
+
[record.protocol, record.sessionId, record.agentCheckoutId, JSON.stringify(record), record.updatedAt]);
|
|
93
|
+
},
|
|
94
|
+
// One statement: a new claim, or a takeover of an unfinished claim whose lease passed.
|
|
95
|
+
async claimOrder(paymentId, { claimId = null, now = Date.now(), leaseMs = 120_000 } = {}) {
|
|
96
|
+
const { rowCount } = await db.query(
|
|
97
|
+
`insert into relyon_order_claims (payment_id, claim_id, expires_at) values ($1, $2, $3)
|
|
98
|
+
on conflict (payment_id) do update set claim_id = excluded.claim_id, expires_at = excluded.expires_at
|
|
99
|
+
where not relyon_order_claims.created and relyon_order_claims.expires_at <= $4`,
|
|
100
|
+
[paymentId, claimId, now + leaseMs, now]);
|
|
101
|
+
return rowCount === 1;
|
|
102
|
+
},
|
|
103
|
+
async completeOrder(paymentId) {
|
|
104
|
+
await db.query(
|
|
105
|
+
`insert into relyon_order_claims (payment_id, created, expires_at) values ($1, true, null)
|
|
106
|
+
on conflict (payment_id) do update set created = true, expires_at = null`, [paymentId]);
|
|
107
|
+
},
|
|
108
|
+
async releaseOrder(paymentId, claimId) {
|
|
109
|
+
await db.query(
|
|
110
|
+
`delete from relyon_order_claims
|
|
111
|
+
where payment_id = $1 and not created and ($2::text is null or claim_id is null or claim_id = $2)`,
|
|
112
|
+
[paymentId, claimId ?? null]);
|
|
113
|
+
},
|
|
114
|
+
async orderClaimStatus(paymentId, now) {
|
|
115
|
+
const { rows } = await db.query(
|
|
116
|
+
"select created, expires_at > $2 as holding from relyon_order_claims where payment_id = $1", [paymentId, now]);
|
|
117
|
+
if (!rows[0]) return null;
|
|
118
|
+
if (rows[0].created) return "created";
|
|
119
|
+
return rows[0].holding ? "creating" : null;
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** AgentEventStore: queued agent events survive restarts until Relyon accepts them. */
|
|
125
|
+
export function postgresAgentEvents(db) {
|
|
126
|
+
return {
|
|
127
|
+
async append(event) {
|
|
128
|
+
await db.query(
|
|
129
|
+
"insert into relyon_agent_events (id, event) values ($1, $2) on conflict (id) do nothing",
|
|
130
|
+
[event.id, JSON.stringify(event)]);
|
|
131
|
+
},
|
|
132
|
+
async peek(limit) {
|
|
133
|
+
const { rows } = await db.query("select event from relyon_agent_events order by seq limit $1", [limit]);
|
|
134
|
+
return rows.map((row) => row.event);
|
|
135
|
+
},
|
|
136
|
+
async remove(ids) {
|
|
137
|
+
if (ids.length > 0) await db.query("delete from relyon_agent_events where id = any($1)", [ids]);
|
|
138
|
+
},
|
|
139
|
+
async size() {
|
|
140
|
+
const { rows } = await db.query("select count(*)::int as n from relyon_agent_events");
|
|
141
|
+
return rows[0].n;
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** CatalogPersistence: the last good catalog, served after a restart. */
|
|
147
|
+
export function postgresCatalog(db) {
|
|
148
|
+
return {
|
|
149
|
+
async load() {
|
|
150
|
+
const { rows } = await db.query("select products from relyon_catalog");
|
|
151
|
+
return rows[0]?.products ?? null;
|
|
152
|
+
},
|
|
153
|
+
async save(products) {
|
|
154
|
+
await db.query(
|
|
155
|
+
`insert into relyon_catalog (singleton, products) values (true, $1)
|
|
156
|
+
on conflict (singleton) do update set products = excluded.products`,
|
|
157
|
+
[JSON.stringify(products)]);
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** The app's own checkout records for checkout-flow.js (relyon-checkout). */
|
|
163
|
+
export function postgresStoreCheckouts(db) {
|
|
164
|
+
const get = async (ref) => {
|
|
165
|
+
const { rows } = await db.query("select record from store_checkouts where order_reference = $1", [ref]);
|
|
166
|
+
return rows[0]?.record ?? null;
|
|
167
|
+
};
|
|
168
|
+
return {
|
|
169
|
+
get,
|
|
170
|
+
async insert(ref, record) {
|
|
171
|
+
await db.query("insert into store_checkouts (order_reference, state, record) values ($1, $2, $3)",
|
|
172
|
+
[ref, record.state, JSON.stringify(record)]);
|
|
173
|
+
},
|
|
174
|
+
// One conditional statement: only one request moves a checkout out of a state.
|
|
175
|
+
async update(ref, expected, record) {
|
|
176
|
+
const { rows } = await db.query(
|
|
177
|
+
`update store_checkouts set state = $3, record = $4, updated_at = now()
|
|
178
|
+
where order_reference = $1 and state = $2 returning record`,
|
|
179
|
+
[ref, expected, record.state, JSON.stringify(record)]);
|
|
180
|
+
return rows[0] ? { updated: true, row: rows[0].record } : { updated: false, row: await get(ref) };
|
|
181
|
+
},
|
|
182
|
+
async confirming() {
|
|
183
|
+
const { rows } = await db.query(
|
|
184
|
+
"select order_reference from store_checkouts where state = 'confirming' order by updated_at limit 100");
|
|
185
|
+
return rows.map((row) => row.order_reference);
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Wire them in when creating the kit (see `SKILL.md`):
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
import pg from "pg";
|
|
195
|
+
import { postgresAgentEvents, postgresCatalog, postgresCheckoutState, postgresStoreCheckouts } from "./durable-state.js";
|
|
196
|
+
import { createRelyonKit } from "./relyon.js";
|
|
197
|
+
|
|
198
|
+
const db = new pg.Pool({ connectionString: process.env.DATABASE_URL });
|
|
199
|
+
export const kit = createRelyonKit({
|
|
200
|
+
state: postgresCheckoutState(db),
|
|
201
|
+
events: postgresAgentEvents(db),
|
|
202
|
+
catalog: postgresCatalog(db),
|
|
203
|
+
});
|
|
204
|
+
// The app's own checkouts (server.js): createApp(kit, { checkouts: postgresStoreCheckouts(db) }).
|
|
205
|
+
export const checkouts = postgresStoreCheckouts(db);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
The app's own orders table should also be unique on the Relyon payment ID, so
|
|
209
|
+
even a bug elsewhere can't record one payment twice (see `relyon-orders`).
|