@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
package/dist/kit.d.ts
ADDED
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import { type OrderConfirmation, type OrderRefusal } from "./confirmation.js";
|
|
2
|
+
import { type AgentDecision, type AgentIdentity, type VerifiedAgentSignal } from "./identify.js";
|
|
3
|
+
import { AgentSignatureVerifier, type AgentVerificationOptions } from "./signatures.js";
|
|
4
|
+
import { WebMcpCheckouts, type CreateWebMcpCheckoutInput, type WebMcpCheckoutPage, type WebMcpOptions } from "./webmcp.js";
|
|
5
|
+
import { CatalogHolder, type CatalogPersistence, type CatalogSyncResult } from "./catalog.js";
|
|
6
|
+
import { type StoreCatalogSource } from "./catalog-reads.js";
|
|
7
|
+
import { type StoreFeedOptions } from "./feeds.js";
|
|
8
|
+
import { type RobotsConflict } from "./robots.js";
|
|
9
|
+
import { type CartTokenResolver } from "./cart-tokens.js";
|
|
10
|
+
import { PaymentOutcomeUnknownError, type CardFields, type CardFieldsInput, type CreatePaymentInput, type CreatePaymentResult, type Landing, type LandingInput } from "./checkout.js";
|
|
11
|
+
import { type KitPaths } from "./context.js";
|
|
12
|
+
import { type ProductJsonLd, type StoreInfo } from "./discovery.js";
|
|
13
|
+
import { AgentEventQueue, type AgentEventQueueOptions } from "./events.js";
|
|
14
|
+
import { type StoreDomain, type StorePolicies, type StorePoliciesInput } from "./setup.js";
|
|
15
|
+
import { RelyonGateway, type RelyonConnection } from "./relyon.js";
|
|
16
|
+
import { type StorePolicyOptions, type StorePolicySyncConfirmed, type StorePolicySyncPlan } from "./policies.js";
|
|
17
|
+
import { AgentRulesCache, type AgentRulesOptions } from "./rules.js";
|
|
18
|
+
import { type CheckoutStateStore } from "./state.js";
|
|
19
|
+
import type { AgentProtocol, Cart, CreateOrder, FindOrderByPaymentId, FulfillmentUpdate, Logger, Order, PaymentCartFormat, PriceCart, RequestInfo, StoreProduct } from "./types.js";
|
|
20
|
+
import { type CartTransferOption, type CartTransferState } from "./cart-transfer.js";
|
|
21
|
+
/** Printed once at startup when `paymentCartFormat: "server-legacy"` is configured. */
|
|
22
|
+
export declare const SERVER_LEGACY_WARNING = "paymentCartFormat \"server-legacy\" is deprecated: Relyon accepts the contract Cart on payments. Remove paymentCartFormat from createStoreKit (the default \"contract\" is right), then restart.";
|
|
23
|
+
/** How long an unfinished order claim holds by default (see `orderClaimLeaseMs`). */
|
|
24
|
+
export declare const DEFAULT_ORDER_CLAIM_LEASE_MS: number;
|
|
25
|
+
export interface StoreKitOptions {
|
|
26
|
+
relyon: RelyonConnection;
|
|
27
|
+
store: StoreInfo & {
|
|
28
|
+
/** The store's public hostnames, verified in Relyon. The first is the primary one. */
|
|
29
|
+
hostnames: string[];
|
|
30
|
+
/**
|
|
31
|
+
* The store's public origin (the app's `STORE_PUBLIC_URL`), such as
|
|
32
|
+
* `https://shop.example.com`. Required in Live mode, where it must be
|
|
33
|
+
* https and name one of `hostnames`; optional in Test (https, or plain
|
|
34
|
+
* http on localhost, naming one of `hostnames`). When set, every
|
|
35
|
+
* agent-facing link (llms.txt, sitemaps, feeds, the UCP profile, MCP
|
|
36
|
+
* results, the agent card, structured data) uses it. When unset, they use
|
|
37
|
+
* the address the request arrived on, if it is one of the store's known
|
|
38
|
+
* hostnames (otherwise the primary hostname).
|
|
39
|
+
*/
|
|
40
|
+
publicUrl?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Test mode only: also answer on the store's preview addresses, so Test
|
|
43
|
+
* agent checkout works before the store is published, on any platform.
|
|
44
|
+
* These are loopback (`localhost`, `127.0.0.1`, `[::1]`; http and a port
|
|
45
|
+
* allowed there only), the hostnames in the RELYON_PREVIEW_HOSTS setting
|
|
46
|
+
* (comma separated), the app's own address when its platform names it in
|
|
47
|
+
* a well-known environment variable (a hint only), and, when this is a
|
|
48
|
+
* list, these hostnames too (a tunnel or any other preview address).
|
|
49
|
+
* Default true; false turns them all off. Ignored in Live mode, which
|
|
50
|
+
* keeps its own rules.
|
|
51
|
+
*/
|
|
52
|
+
previewHosts?: boolean | readonly string[];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The root sitemap at `/sitemap.xml`: a `urlset` of the product pages (the
|
|
56
|
+
* same list as the product sitemap). Default true; set false when the store
|
|
57
|
+
* already serves its own `/sitemap.xml` (then list the product sitemap in it).
|
|
58
|
+
*/
|
|
59
|
+
sitemapIndex?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The agent card at `/.well-known/agent-card.json`: how shopping agents buy
|
|
62
|
+
* here (UCP, ACP, MCP) and the AP2 checkout-mandate extension. It claims
|
|
63
|
+
* only what the kit serves. Default true; false turns it off.
|
|
64
|
+
*/
|
|
65
|
+
agentCard?: boolean;
|
|
66
|
+
/** The store prices every cart. */
|
|
67
|
+
priceCart: PriceCart;
|
|
68
|
+
/** Creates the store's order for a succeeded payment; called exactly once per payment. */
|
|
69
|
+
createOrder: CreateOrder;
|
|
70
|
+
/**
|
|
71
|
+
* Optional, read-only: the store's existing order for a payment ID. When a
|
|
72
|
+
* replayed `createPayment` finds the order already created
|
|
73
|
+
* (`orderStatus: "already_created"`), the kit calls it and returns what it
|
|
74
|
+
* found as `order`, so a resend gets the same order back. Without it (or
|
|
75
|
+
* when it returns null or throws) `order` is absent on a replay.
|
|
76
|
+
*/
|
|
77
|
+
findOrderByPaymentId?: FindOrderByPaymentId;
|
|
78
|
+
paths?: Partial<KitPaths>;
|
|
79
|
+
events?: AgentEventQueueOptions;
|
|
80
|
+
rules?: AgentRulesOptions;
|
|
81
|
+
/** Per-checkout memory and the create-order claim. Default: in memory (one process). */
|
|
82
|
+
state?: CheckoutStateStore;
|
|
83
|
+
/**
|
|
84
|
+
* How long an order claim that wasn't marked created holds (ms) before
|
|
85
|
+
* another request may take it over, in case the server creating the order
|
|
86
|
+
* died. Make it longer than `createOrder` ever takes. Default 2 minutes.
|
|
87
|
+
*/
|
|
88
|
+
orderClaimLeaseMs?: number;
|
|
89
|
+
/**
|
|
90
|
+
* `relyon_cart` tokens: a resolver, or a secret for the kit's own sealed
|
|
91
|
+
* tokens. Default: sealed tokens keyed from the Relyon API key.
|
|
92
|
+
*/
|
|
93
|
+
cartTokens?: CartTokenResolver | {
|
|
94
|
+
secret: string;
|
|
95
|
+
ttlSeconds?: number;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* UCP cart transfer (`POST <ucp prefix>/carts`, answered by the kit from the
|
|
99
|
+
* store's catalog and `priceCart`; nothing goes to Relyon). Test: on by
|
|
100
|
+
* default, open unless a caller key is set. Live: on only with a key.
|
|
101
|
+
* `false` switches it off. See `docs/cart-transfer.md` in the kit's source.
|
|
102
|
+
*/
|
|
103
|
+
cartTransfer?: CartTransferOption;
|
|
104
|
+
catalog?: {
|
|
105
|
+
initial?: StoreProduct[];
|
|
106
|
+
persistence?: CatalogPersistence;
|
|
107
|
+
source?: StoreCatalogSource;
|
|
108
|
+
};
|
|
109
|
+
/** Opt-in, store-callback-backed files only. No mirror fallback. */
|
|
110
|
+
feeds?: StoreFeedOptions;
|
|
111
|
+
/**
|
|
112
|
+
* `/robots.txt`. By default the kit serves one that lets the AI search and
|
|
113
|
+
* shopping crawlers read the store (with the sitemap and llms.txt links).
|
|
114
|
+
* A store with its own robots policy passes `existing` (its current text);
|
|
115
|
+
* the kit merges into it and conflicts preserve the existing content.
|
|
116
|
+
* `false` opts out: the kit never answers /robots.txt.
|
|
117
|
+
*/
|
|
118
|
+
robots?: false | {
|
|
119
|
+
existing: () => string | Promise<string>;
|
|
120
|
+
onConflict?: (conflicts: readonly RobotsConflict[]) => void;
|
|
121
|
+
};
|
|
122
|
+
/** Overrides where the card-field script loads from. Default: next to the Relyon API. */
|
|
123
|
+
cardFieldsScriptUrl?: string;
|
|
124
|
+
/** Largest request body the kit reads, in bytes. Default 1 MiB. */
|
|
125
|
+
maxBodyBytes?: number;
|
|
126
|
+
/**
|
|
127
|
+
* The cart shape sent with `createPayment`. `contract` (default) sends the v1
|
|
128
|
+
* contract's `Cart`, which Relyon accepts. `server-legacy` (deprecated; the
|
|
129
|
+
* kit warns at startup) sends the old shape (lines keyed by `product_id`;
|
|
130
|
+
* no top-level `currency`, `shipping_options` or line `id`). Remove it.
|
|
131
|
+
*/
|
|
132
|
+
paymentCartFormat?: PaymentCartFormat;
|
|
133
|
+
/**
|
|
134
|
+
* Browser-agent identification. The kit verifies Web Bot Auth, Visa
|
|
135
|
+
* TAP and Mastercard Agent Pay signatures locally for edge decisions only;
|
|
136
|
+
* Relyon stays the authority on agent names. `verify: false` turns the
|
|
137
|
+
* local check off (every agent is then "claimed"). `failClosed` (default
|
|
138
|
+
* true) refuses an identified agent's checkout steps and payment when the
|
|
139
|
+
* agent rules can't be read; people and discovery are never affected.
|
|
140
|
+
*/
|
|
141
|
+
agents?: AgentVerificationOptions & {
|
|
142
|
+
verify?: boolean;
|
|
143
|
+
failClosed?: boolean;
|
|
144
|
+
};
|
|
145
|
+
/** WebMCP checkout tools on the store's checkout page. */
|
|
146
|
+
webmcp?: WebMcpOptions;
|
|
147
|
+
/**
|
|
148
|
+
* The store's own policy pages and returns terms. Published in UCP and ACP
|
|
149
|
+
* checkout `links`, `llms.txt` and product JSON-LD (`hasMerchantReturnPolicy`).
|
|
150
|
+
* The kit never states a return cost. See "Store policies" in the README.
|
|
151
|
+
*/
|
|
152
|
+
policies?: StorePolicyOptions;
|
|
153
|
+
now?: () => number;
|
|
154
|
+
logger?: Logger;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The store kit: everything an agent or shopper reaches on the store's own
|
|
158
|
+
* domain that involves Relyon. The store supplies `priceCart` and
|
|
159
|
+
* `createOrder`; the kit does the rest.
|
|
160
|
+
*/
|
|
161
|
+
export declare class StoreKit {
|
|
162
|
+
private readonly options;
|
|
163
|
+
readonly gateway: RelyonGateway;
|
|
164
|
+
readonly events: AgentEventQueue;
|
|
165
|
+
readonly rules: AgentRulesCache;
|
|
166
|
+
readonly catalog: CatalogHolder;
|
|
167
|
+
readonly paths: KitPaths;
|
|
168
|
+
readonly cartTokens: CartTokenResolver;
|
|
169
|
+
/** Whether UCP cart transfer runs (see `StoreKitOptions.cartTransfer`). */
|
|
170
|
+
readonly cartTransfer: CartTransferState;
|
|
171
|
+
private readonly transferTokens;
|
|
172
|
+
readonly maxBodyBytes: number;
|
|
173
|
+
/** The local agent-signature verifier; null when `agents.verify` is false. */
|
|
174
|
+
readonly verifier: AgentSignatureVerifier | null;
|
|
175
|
+
/** WebMCP checkouts for the store's checkout page. */
|
|
176
|
+
readonly webmcp: WebMcpCheckouts;
|
|
177
|
+
private readonly identities;
|
|
178
|
+
private readonly ctx;
|
|
179
|
+
private readonly discovery;
|
|
180
|
+
private readonly catalogReads;
|
|
181
|
+
private readonly feeds;
|
|
182
|
+
private readonly mcp;
|
|
183
|
+
private readonly hostnames;
|
|
184
|
+
/** The origin of `store.publicUrl`, when set. */
|
|
185
|
+
private readonly configuredOrigin;
|
|
186
|
+
private chatgptChannel;
|
|
187
|
+
/** The validated `policies` option. */
|
|
188
|
+
readonly policies: Readonly<StorePolicyOptions> | undefined;
|
|
189
|
+
private readonly logger;
|
|
190
|
+
private readonly now;
|
|
191
|
+
private started;
|
|
192
|
+
/** The usable rly_test_ key in Test (signs test-checkout proofs); undefined in Live or without one. */
|
|
193
|
+
private readonly testKey;
|
|
194
|
+
private readonly testCheckoutNonces;
|
|
195
|
+
private readonly testCheckoutRuns;
|
|
196
|
+
/**
|
|
197
|
+
* True when this kit runs in Live mode: the explicit `relyon.live: true`
|
|
198
|
+
* opt-in with a Live key. Never inferred from the key prefix alone.
|
|
199
|
+
*/
|
|
200
|
+
get livemode(): boolean;
|
|
201
|
+
/** Show this on the checkout page. Restart with real server configuration to activate; no rebuild needed. */
|
|
202
|
+
get checkoutStatus(): "ready" | "waiting for sandbox key";
|
|
203
|
+
constructor(options: StoreKitOptions);
|
|
204
|
+
/** Restores the saved catalog, starts the event timer and reads the agent rules. Idempotent. */
|
|
205
|
+
start(): Promise<void>;
|
|
206
|
+
/** Stops the timers and sends what's queued (best effort). */
|
|
207
|
+
stop(): Promise<void>;
|
|
208
|
+
/**
|
|
209
|
+
* The configured hostname this request was addressed to; the primary one if
|
|
210
|
+
* it names none of them. Behind a proxy, a loopback URL host is the internal
|
|
211
|
+
* side: a forwarded store hostname (including a Test loopback name from a
|
|
212
|
+
* local dev proxy) wins over it. Used for this request's own checkout
|
|
213
|
+
* addressing (agent signatures, hand-offs, status URLs), never for links in
|
|
214
|
+
* shared documents; those use `publicOrigin(request)`.
|
|
215
|
+
*/
|
|
216
|
+
publicHost(request: Request): string;
|
|
217
|
+
/**
|
|
218
|
+
* The hostname for links in shared, cacheable documents. Like `publicHost`,
|
|
219
|
+
* except a forwarded host never selects a loopback origin: a proxy
|
|
220
|
+
* presenting a public request does not name loopback, so such a value may
|
|
221
|
+
* be a client's own header passed through, and it must not reach links a
|
|
222
|
+
* cache could serve to others. A request that came through a proxy (it
|
|
223
|
+
* names a forwarded host) never gets the backend's loopback origin either:
|
|
224
|
+
* an unusable forwarded host falls back to the primary.
|
|
225
|
+
*/
|
|
226
|
+
private linkHost;
|
|
227
|
+
/** The request's own URL on the known host it arrived on (used to check agent signatures). */
|
|
228
|
+
publicUrl(request: Request): string;
|
|
229
|
+
/**
|
|
230
|
+
* The store's public address for agent-facing links on this request:
|
|
231
|
+
* `store.publicUrl` (STORE_PUBLIC_URL) when set; otherwise the known
|
|
232
|
+
* hostname the request arrived on (an unknown Host header falls back to
|
|
233
|
+
* the primary hostname; see `linkHost` for forwarded loopback hosts). Every
|
|
234
|
+
* link in llms.txt, the sitemaps, feeds, the UCP profile, MCP results, the
|
|
235
|
+
* agent card and the structured-data helpers is built on it.
|
|
236
|
+
*/
|
|
237
|
+
publicOrigin(request: Request): string;
|
|
238
|
+
/** The hostname of `publicOrigin(request)`. */
|
|
239
|
+
private publicOriginHost;
|
|
240
|
+
/**
|
|
241
|
+
* The store's origin as this request reached it, for this request's own
|
|
242
|
+
* checkout addressing: `https://<host>`, except a Test loopback store, which
|
|
243
|
+
* keeps the request's own scheme and port (plain http on localhost with a
|
|
244
|
+
* port), or the forwarded loopback host and port a local dev proxy names.
|
|
245
|
+
*/
|
|
246
|
+
private requestOrigin;
|
|
247
|
+
/** The request's URL, with an unspecified bind address replaced by a validated Host (Test only; see `requestUrl`). */
|
|
248
|
+
private requestUrl;
|
|
249
|
+
/**
|
|
250
|
+
* A `303 See Other` to `path` on this store, for the app's own routes (a
|
|
251
|
+
* cart form, "Buy now", after a POST). The Location is `path` on the
|
|
252
|
+
* request's validated origin: the store hostname the request arrived on
|
|
253
|
+
* (in Test a loopback address keeps its scheme and port, and a dev server
|
|
254
|
+
* bound to `0.0.0.0` or `[::]` uses the Host header the browser sent); an
|
|
255
|
+
* unknown Host falls back to the primary hostname. Never build a redirect
|
|
256
|
+
* from `request.url`: on a server bound to every interface it names
|
|
257
|
+
* `0.0.0.0`, which no browser can open.
|
|
258
|
+
*
|
|
259
|
+
* `path` must start with a single `/` (such as `/checkout?product=mug`);
|
|
260
|
+
* a full URL, `//host`, or anything that leaves the store's origin throws
|
|
261
|
+
* a TypeError. `init.headers` (such as Set-Cookie) are added to the answer.
|
|
262
|
+
*/
|
|
263
|
+
redirect(request: Request, path: string, init?: {
|
|
264
|
+
headers?: HeadersInit;
|
|
265
|
+
}): Response;
|
|
266
|
+
/** True when the kit serves the agent card. */
|
|
267
|
+
private get servesAgentCard();
|
|
268
|
+
/** True when the kit serves the root sitemap at /sitemap.xml. */
|
|
269
|
+
private get servesSitemapIndex();
|
|
270
|
+
/** True for a path the kit answers (any method). Adapters use it to read bodies only for the kit's routes. */
|
|
271
|
+
matches(pathname: string): boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Answers a request the kit serves, or returns null so the store's own
|
|
274
|
+
* routes handle it. Never throws for a bad request.
|
|
275
|
+
*/
|
|
276
|
+
handle(request: Request, info?: RequestInfo): Promise<Response | null>;
|
|
277
|
+
/** Reports a crawler or agent visit to a page the store serves itself (a product page, say). */
|
|
278
|
+
recordCrawlerVisit(request: Request, status: number, info?: RequestInfo): void;
|
|
279
|
+
private readBody;
|
|
280
|
+
/** Refuses a blocked agent at the edge (claimed or verified); never fails closed (discovery and relays). */
|
|
281
|
+
private edgeBlock;
|
|
282
|
+
private pausedRefusal;
|
|
283
|
+
private report;
|
|
284
|
+
private discoveryRead;
|
|
285
|
+
/** While the kit waits for a sandbox key, every discovery answer says so (no configuration). */
|
|
286
|
+
private waitingHeaders;
|
|
287
|
+
private discoveryCatalog;
|
|
288
|
+
/** True when the kit can answer cart transfer at the profile's advertised REST endpoint. */
|
|
289
|
+
private get cartTransferCallable();
|
|
290
|
+
/**
|
|
291
|
+
* The UCP profile the store serves: Relyon's 2026-08-25 body plus the cart
|
|
292
|
+
* capability and `supported_versions` (or, for `leaf`, the derived
|
|
293
|
+
* 2026-04-08 profile). Refusals and the cache headers pass through.
|
|
294
|
+
*/
|
|
295
|
+
private servedProfile;
|
|
296
|
+
/** `POST <ucp prefix>/carts`: answered by the kit alone (see cart-transfer.ts). */
|
|
297
|
+
private cartTransferRequest;
|
|
298
|
+
private checkoutRequest;
|
|
299
|
+
private mcpRequest;
|
|
300
|
+
private webhook;
|
|
301
|
+
/**
|
|
302
|
+
* Who is at this request: verified from an allowlisted agent signature, or
|
|
303
|
+
* as it claims (user agent, Signature-Agent, UCP-Agent, MCP client), with
|
|
304
|
+
* behaviour hints recorded as claims only. Cached per Request object.
|
|
305
|
+
*/
|
|
306
|
+
identifyAgent(request: Request, options?: {
|
|
307
|
+
mcpClientName?: string;
|
|
308
|
+
hints?: readonly string[];
|
|
309
|
+
}): Promise<AgentIdentity>;
|
|
310
|
+
/**
|
|
311
|
+
* The edge answer for a checkout step or payment: allow, refuse by a named
|
|
312
|
+
* Relyon rule, or (for an identified agent, when the rules can't be read)
|
|
313
|
+
* unavailable. Never a challenge or a blanket block.
|
|
314
|
+
*/
|
|
315
|
+
agentDecision(request: Request, options?: {
|
|
316
|
+
hints?: readonly string[];
|
|
317
|
+
}): Promise<AgentDecision>;
|
|
318
|
+
/**
|
|
319
|
+
* The verified-agent signal for the store's own bot protection: skip a
|
|
320
|
+
* CAPTCHA or WAF challenge only when `skipChallenge` is true (a verified
|
|
321
|
+
* signature Relyon's rules allow). See the README's bot-protection guidance.
|
|
322
|
+
*/
|
|
323
|
+
verifiedAgent(request: Request): Promise<VerifiedAgentSignal>;
|
|
324
|
+
/** Starts a WebMCP checkout for the store's checkout page. */
|
|
325
|
+
createWebMcpCheckout(input: CreateWebMcpCheckoutInput): Promise<WebMcpCheckoutPage>;
|
|
326
|
+
/** The machine-readable order confirmation for a paid cart. */
|
|
327
|
+
orderConfirmation(cart: Cart, orderReference: string, result: CreatePaymentResult): OrderConfirmation;
|
|
328
|
+
/**
|
|
329
|
+
* For the store's own pay endpoint: runs `createPayment` and answers JSON
|
|
330
|
+
* with the order confirmation (200), the decline (402), the refusal
|
|
331
|
+
* naming the Relyon rule (403/503, or Relyon's own status), an unknown
|
|
332
|
+
* outcome (202, `payment_outcome: "unknown"`), or order pending (202,
|
|
333
|
+
* `payment_outcome: "succeeded"`, `order_status: "pending"`: the payment
|
|
334
|
+
* went through and `createOrder` failed or is still running elsewhere).
|
|
335
|
+
* After either 202, retry by calling this again with the SAME input (order
|
|
336
|
+
* reference, attempt and the original `paymentMethod`); never re-read the
|
|
337
|
+
* card. The retry replays the payment (no new charge) and creates the
|
|
338
|
+
* order once. When the pending payment belongs to an earlier attempt of
|
|
339
|
+
* the order reference, or to another order reference for the same agent
|
|
340
|
+
* checkout, the 202 names it (`paid_order_reference`, `paid_attempt`):
|
|
341
|
+
* resend that request instead.
|
|
342
|
+
*
|
|
343
|
+
* Once the key, its order reference or its agent checkout may have been
|
|
344
|
+
* charged, no answer says nothing was charged: every refusal (the kit's
|
|
345
|
+
* own gate, or Relyon's) and every unexpected error answers order pending
|
|
346
|
+
* when the kit remembers a pending order, otherwise charge-neutrally.
|
|
347
|
+
* Unexpected errors are answered (500, `internal_error`), not thrown.
|
|
348
|
+
*/
|
|
349
|
+
payAndConfirm(input: CreatePaymentInput): Promise<{
|
|
350
|
+
response: Response;
|
|
351
|
+
confirmation?: OrderConfirmation;
|
|
352
|
+
refusal?: OrderRefusal;
|
|
353
|
+
result?: CreatePaymentResult;
|
|
354
|
+
outcomeUnknown?: PaymentOutcomeUnknownError;
|
|
355
|
+
orderPending?: boolean;
|
|
356
|
+
}>;
|
|
357
|
+
/** `payAndConfirm`'s 202 unknown-outcome answer. */
|
|
358
|
+
private payOutcomeUnknown;
|
|
359
|
+
/**
|
|
360
|
+
* `payAndConfirm`'s answer to a refusal or an unexpected error. A pending
|
|
361
|
+
* order the kit remembers (this key, an earlier attempt of the order
|
|
362
|
+
* reference, or another payment for the agent checkout) answers 202 order
|
|
363
|
+
* pending. Otherwise, when anything may have been charged, the refusal is
|
|
364
|
+
* charge-neutral; Relyon's refusal of a request it never charged, or a
|
|
365
|
+
* gate refusal of an established-unpaid key, keeps its own wording.
|
|
366
|
+
*/
|
|
367
|
+
private payRefusal;
|
|
368
|
+
/** `payAndConfirm`'s 202 order-pending answer; `paid` names an earlier attempt or order reference that paid. */
|
|
369
|
+
private payOrderPending;
|
|
370
|
+
/**
|
|
371
|
+
* True when a succeeded payment's order isn't created: `createOrder` threw,
|
|
372
|
+
* or another request holds the claim on a store that can report claim
|
|
373
|
+
* status. Without `orderClaimStatus` an in-progress claim can't be told
|
|
374
|
+
* from a created order, so it confirms (as before) and logs a warning.
|
|
375
|
+
*/
|
|
376
|
+
private orderIsPending;
|
|
377
|
+
/** The confirmation page fragment: JSON-LD plus the `#relyon-order-confirmation` element. */
|
|
378
|
+
renderOrderConfirmation(confirmation: OrderConfirmation): string;
|
|
379
|
+
/** What the confirmation page shows for a refused or declined payment. */
|
|
380
|
+
renderOrderRefusal(refusal: OrderRefusal): string;
|
|
381
|
+
/**
|
|
382
|
+
* Upserts the store's catalog into Relyon and keeps it as the last good
|
|
383
|
+
* catalog for discovery. Relyon's index takes full URLs only, so each
|
|
384
|
+
* product's `url` and `images` that are the store's own (a path such as
|
|
385
|
+
* `/products/mug`, or a URL on one of the store's hostnames or loopback)
|
|
386
|
+
* are sent on the store's public address: `store.publicUrl`
|
|
387
|
+
* (STORE_PUBLIC_URL) when set, else `https://` + the primary hostname, the
|
|
388
|
+
* same default the feeds use. The kit's own catalog keeps the links as
|
|
389
|
+
* given. When a path can't be made a full URL (no STORE_PUBLIC_URL and a
|
|
390
|
+
* loopback primary hostname, whose port the kit can't know) the sync
|
|
391
|
+
* throws a CatalogSyncError naming the product and the fix before anything
|
|
392
|
+
* is sent.
|
|
393
|
+
*/
|
|
394
|
+
syncCatalog(products: StoreProduct[], options?: {
|
|
395
|
+
mode?: "upsert" | "full";
|
|
396
|
+
}): Promise<CatalogSyncResult>;
|
|
397
|
+
/** `POST /relyon/test-checkout`: one Test purchase for `npx @relyon/store-kit test-checkout` (see test-checkout.ts). */
|
|
398
|
+
private testCheckout;
|
|
399
|
+
/** The origin synced product links go on; undefined when no usable one is known. */
|
|
400
|
+
private syncOrigin;
|
|
401
|
+
/** Creates a payment session and renders `<relyon-card-fields>` for the checkout page. */
|
|
402
|
+
cardFields(input: CardFieldsInput): Promise<CardFields>;
|
|
403
|
+
/** Charges the cart through `createPayment`; creates the store's order once on success. */
|
|
404
|
+
createPayment(input: CreatePaymentInput): Promise<CreatePaymentResult>;
|
|
405
|
+
/**
|
|
406
|
+
* Reads a landing on the store's checkout page: an agent hand-off
|
|
407
|
+
* (`relyon_cart`) or a UCP cart transfer (`relyon_transfer`). Pass the
|
|
408
|
+
* page's Request, or (for a Next.js server component) its URL or its
|
|
409
|
+
* awaited `searchParams`.
|
|
410
|
+
*/
|
|
411
|
+
landing(request: LandingInput, info?: RequestInfo): Promise<Landing>;
|
|
412
|
+
/** The checkout page request for `landing()`: a URL, a path or search params land on the store's checkout path. */
|
|
413
|
+
private landingRequest;
|
|
414
|
+
/**
|
|
415
|
+
* The store checkout URL that hands an agent's cart to a shopper, with a
|
|
416
|
+
* `relyon_cart` token for the agent checkout. null when the kit doesn't know it.
|
|
417
|
+
*/
|
|
418
|
+
handoffUrl(protocol: AgentProtocol, sessionId: string, hostname?: string): Promise<string | null>;
|
|
419
|
+
/** Reports a shipped, delivered or canceled order. */
|
|
420
|
+
reportFulfillment(orderId: string, update: FulfillmentUpdate): Promise<Order>;
|
|
421
|
+
/**
|
|
422
|
+
* Adds the store's hostname (default: the primary one) as a Relyon domain,
|
|
423
|
+
* unless Relyon has it already, and returns it. Only the store's own
|
|
424
|
+
* configured hostnames are accepted.
|
|
425
|
+
*/
|
|
426
|
+
ensureDomain(hostname?: string): Promise<StoreDomain>;
|
|
427
|
+
/**
|
|
428
|
+
* Adds the hostname if needed, then asks Relyon to verify it. Relyon reads
|
|
429
|
+
* `/.well-known/relyon-verification` from this store (or the DNS TXT record)
|
|
430
|
+
* while the call runs, so the kit must already be serving the hostname.
|
|
431
|
+
* A verified domain is returned as it is; a pending or failed one is
|
|
432
|
+
* checked again. Resolves with the domain after the check: look at
|
|
433
|
+
* `status` and `failure_reason`.
|
|
434
|
+
*/
|
|
435
|
+
verifyDomain(hostname?: string): Promise<StoreDomain>;
|
|
436
|
+
/** The store's return, support and consumer-notice policies, with `complete` and `missing`. */
|
|
437
|
+
storePolicies(): Promise<StorePolicies>;
|
|
438
|
+
/** Replaces every store policy field (an omitted field is cleared). Incomplete policies are stored and reported. */
|
|
439
|
+
replaceStorePolicies(input: StorePoliciesInput): Promise<StorePolicies>;
|
|
440
|
+
/**
|
|
441
|
+
* Keeps Relyon's store policies in step with the store's own policy pages
|
|
442
|
+
* (the `policies` option). Without `confirm: true` it only reads and
|
|
443
|
+
* returns the plan: every field it would change (`changes`) and what the
|
|
444
|
+
* merchant must still supply (`needs`). Show the changes to the merchant;
|
|
445
|
+
* once they confirm, call again with `confirm: true` to replace the
|
|
446
|
+
* policies. A return cost comes only from `returns` here or a cost already
|
|
447
|
+
* stored in Relyon: the kit never infers free returns or a return cost.
|
|
448
|
+
*/
|
|
449
|
+
syncStorePolicies(options?: StorePolicySyncConfirmed & {
|
|
450
|
+
confirm?: boolean;
|
|
451
|
+
}): Promise<StorePolicySyncPlan & {
|
|
452
|
+
applied: boolean;
|
|
453
|
+
policies: StorePolicies;
|
|
454
|
+
}>;
|
|
455
|
+
/**
|
|
456
|
+
* The policy pages as Relyon stores them: Relyon keeps only public https
|
|
457
|
+
* pages, so a Test store's local http policy URL (localhost, 127.0.0.1,
|
|
458
|
+
* [::1]) is sent on the store's https public address (STORE_PUBLIC_URL), or
|
|
459
|
+
* refused with the fix when the kit doesn't know one. Nothing is sent then.
|
|
460
|
+
*/
|
|
461
|
+
private policiesForRelyon;
|
|
462
|
+
private ownHostname;
|
|
463
|
+
/**
|
|
464
|
+
* schema.org `Product` JSON-LD for a product page. With the page's
|
|
465
|
+
* `request`, links on the store's own hostnames (and dev addresses) are
|
|
466
|
+
* moved onto `publicOrigin(request)`.
|
|
467
|
+
*/
|
|
468
|
+
productJsonLd(product: StoreProduct, request?: Request): ProductJsonLd;
|
|
469
|
+
renderProductJsonLd(product: StoreProduct, request?: Request): string;
|
|
470
|
+
/**
|
|
471
|
+
* schema.org `ItemList` JSON-LD for the homepage product list: each entry
|
|
472
|
+
* carries the product's name, price, currency, availability, brand and
|
|
473
|
+
* `sku` (`gtin` / `mpn` only when supplied). At most 100 products.
|
|
474
|
+
*/
|
|
475
|
+
productListJsonLd(products: readonly StoreProduct[], request?: Request): Record<string, unknown>;
|
|
476
|
+
renderProductListJsonLd(products: readonly StoreProduct[], request?: Request): string;
|
|
477
|
+
/**
|
|
478
|
+
* Where agents find the store, for the homepage `<head>`: llms.txt, the
|
|
479
|
+
* UCP profile, the MCP server, the ACP checkout endpoint, the agent card,
|
|
480
|
+
* the product sitemap and every feed the store serves, all on
|
|
481
|
+
* `publicOrigin(request)`.
|
|
482
|
+
*/
|
|
483
|
+
discoveryLinks(request: Request): {
|
|
484
|
+
rel: string;
|
|
485
|
+
href: string;
|
|
486
|
+
type: string;
|
|
487
|
+
title: string;
|
|
488
|
+
}[];
|
|
489
|
+
/** `discoveryLinks(request)` as `<link>` tags for the homepage `<head>`. */
|
|
490
|
+
renderDiscoveryLinks(request: Request): string;
|
|
491
|
+
/**
|
|
492
|
+
* Whether Relyon reports this store's ChatGPT channel approved and
|
|
493
|
+
* connected (`GET /v1/channels/chatgpt` status `connected`, same mode).
|
|
494
|
+
* Read at most once a minute; a failed read counts as not connected.
|
|
495
|
+
*/
|
|
496
|
+
private chatgptConnected;
|
|
497
|
+
}
|
|
498
|
+
export declare class BodyTooLargeError extends Error {
|
|
499
|
+
constructor();
|
|
500
|
+
}
|
|
501
|
+
export declare function createStoreKit(options: StoreKitOptions): StoreKit;
|
|
502
|
+
/**
|
|
503
|
+
* `createKit`'s options: the store kit's, with the project space in place of
|
|
504
|
+
* `store`. `projectSpace.publicUrl` defaults to PUBLIC_URL (else
|
|
505
|
+
* STORE_PUBLIC_URL) and `projectSpace.id` to RELYON_PROJECT_SPACE.
|
|
506
|
+
*/
|
|
507
|
+
export interface KitOptions extends Omit<StoreKitOptions, "store"> {
|
|
508
|
+
projectSpace: StoreKitOptions["store"] & {
|
|
509
|
+
/** The project space's ID (`prj_…`), sent as `Relyon-Project-Space`; optional in a single-space workspace. */
|
|
510
|
+
id?: string;
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
/** The kit (products, agents and shopping pages); `StoreKit` is its old name. */
|
|
514
|
+
export type Kit = StoreKit;
|
|
515
|
+
/** Creates the kit from project-space options (or the store kit's, unchanged). */
|
|
516
|
+
export declare function createKit(options: KitOptions | StoreKitOptions): Kit;
|