@relyon/kit 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/AGENTS.md +75 -0
  2. package/CHANGELOG.md +1053 -0
  3. package/LICENSE +21 -0
  4. package/QUICKSTART.md +239 -0
  5. package/README.md +117 -2
  6. package/dist/adapters/express.d.ts +39 -0
  7. package/dist/adapters/express.js +106 -0
  8. package/dist/adapters/hono.d.ts +16 -0
  9. package/dist/adapters/hono.js +15 -0
  10. package/dist/adapters/next.d.ts +29 -0
  11. package/dist/adapters/next.js +38 -0
  12. package/dist/agent-card.d.ts +14 -0
  13. package/dist/agent-card.js +58 -0
  14. package/dist/agent-docs.d.ts +36 -0
  15. package/dist/agent-docs.js +78 -0
  16. package/dist/agent-hooks.d.ts +66 -0
  17. package/dist/agent-hooks.js +280 -0
  18. package/dist/agents.d.ts +24 -0
  19. package/dist/agents.js +120 -0
  20. package/dist/api-key.d.ts +6 -0
  21. package/dist/api-key.js +33 -0
  22. package/dist/cache.d.ts +46 -0
  23. package/dist/cache.js +86 -0
  24. package/dist/cart-tokens.d.ts +31 -0
  25. package/dist/cart-tokens.js +58 -0
  26. package/dist/cart-transfer.d.ts +95 -0
  27. package/dist/cart-transfer.js +387 -0
  28. package/dist/catalog-enrichment.d.ts +6 -0
  29. package/dist/catalog-enrichment.js +71 -0
  30. package/dist/catalog-reads.d.ts +126 -0
  31. package/dist/catalog-reads.js +104 -0
  32. package/dist/catalog.d.ts +78 -0
  33. package/dist/catalog.js +288 -0
  34. package/dist/charge-claims.d.ts +11 -0
  35. package/dist/charge-claims.js +47 -0
  36. package/dist/check.d.ts +44 -0
  37. package/dist/check.js +152 -0
  38. package/dist/checklist-manifest.d.ts +72 -0
  39. package/dist/checklist-manifest.js +341 -0
  40. package/dist/checkout.d.ts +222 -0
  41. package/dist/checkout.js +353 -0
  42. package/dist/cli.d.ts +2 -0
  43. package/dist/cli.js +727 -0
  44. package/dist/confirmation.d.ts +78 -0
  45. package/dist/confirmation.js +124 -0
  46. package/dist/context.d.ts +81 -0
  47. package/dist/context.js +10 -0
  48. package/dist/discovery.d.ts +151 -0
  49. package/dist/discovery.js +346 -0
  50. package/dist/doctor-cart-transfer.d.ts +33 -0
  51. package/dist/doctor-cart-transfer.js +186 -0
  52. package/dist/doctor-catalog.d.ts +8 -0
  53. package/dist/doctor-catalog.js +47 -0
  54. package/dist/doctor-evidence.d.ts +22 -0
  55. package/dist/doctor-evidence.js +57 -0
  56. package/dist/doctor-merchant.d.ts +48 -0
  57. package/dist/doctor-merchant.js +74 -0
  58. package/dist/doctor-source.d.ts +5 -0
  59. package/dist/doctor-source.js +142 -0
  60. package/dist/doctor-variants.d.ts +70 -0
  61. package/dist/doctor-variants.js +102 -0
  62. package/dist/doctor.d.ts +215 -0
  63. package/dist/doctor.js +1689 -0
  64. package/dist/events.d.ts +95 -0
  65. package/dist/events.js +200 -0
  66. package/dist/feed-mapping.d.ts +114 -0
  67. package/dist/feed-mapping.js +152 -0
  68. package/dist/feed-values.d.ts +13 -0
  69. package/dist/feed-values.js +40 -0
  70. package/dist/feeds.d.ts +104 -0
  71. package/dist/feeds.js +366 -0
  72. package/dist/identify.d.ts +102 -0
  73. package/dist/identify.js +124 -0
  74. package/dist/identity.d.ts +37 -0
  75. package/dist/identity.js +54 -0
  76. package/dist/index.d.ts +42 -0
  77. package/dist/index.js +41 -0
  78. package/dist/init.d.ts +157 -0
  79. package/dist/init.js +912 -0
  80. package/dist/kit-config.d.ts +19 -0
  81. package/dist/kit-config.js +43 -0
  82. package/dist/kit-environment.d.ts +20 -0
  83. package/dist/kit-environment.js +32 -0
  84. package/dist/kit-updates.d.ts +47 -0
  85. package/dist/kit-updates.js +77 -0
  86. package/dist/kit-version-project.d.ts +18 -0
  87. package/dist/kit-version-project.js +214 -0
  88. package/dist/kit-version.d.ts +37 -0
  89. package/dist/kit-version.js +162 -0
  90. package/dist/kit.d.ts +516 -0
  91. package/dist/kit.js +1309 -0
  92. package/dist/layers/pages.d.ts +3 -0
  93. package/dist/layers/pages.js +5 -0
  94. package/dist/layers/payments.d.ts +7 -0
  95. package/dist/layers/payments.js +9 -0
  96. package/dist/layers/products.d.ts +10 -0
  97. package/dist/layers/products.js +13 -0
  98. package/dist/live.d.ts +13 -0
  99. package/dist/live.js +52 -0
  100. package/dist/mcp.d.ts +270 -0
  101. package/dist/mcp.js +312 -0
  102. package/dist/next-steps.d.ts +101 -0
  103. package/dist/next-steps.js +257 -0
  104. package/dist/order-pending.d.ts +57 -0
  105. package/dist/order-pending.js +127 -0
  106. package/dist/orders.d.ts +12 -0
  107. package/dist/orders.js +21 -0
  108. package/dist/payments-init.d.ts +19 -0
  109. package/dist/payments-init.js +70 -0
  110. package/dist/payments-routes.d.ts +54 -0
  111. package/dist/payments-routes.js +123 -0
  112. package/dist/payments.d.ts +165 -0
  113. package/dist/payments.js +192 -0
  114. package/dist/pnpm-workspace.d.ts +58 -0
  115. package/dist/pnpm-workspace.js +250 -0
  116. package/dist/policies.d.ts +111 -0
  117. package/dist/policies.js +317 -0
  118. package/dist/preview-hosts.d.ts +64 -0
  119. package/dist/preview-hosts.js +175 -0
  120. package/dist/private-config.d.ts +169 -0
  121. package/dist/private-config.js +820 -0
  122. package/dist/progress.d.ts +54 -0
  123. package/dist/progress.js +153 -0
  124. package/dist/protocol-inputs.d.ts +22 -0
  125. package/dist/protocol-inputs.js +151 -0
  126. package/dist/public-origin.d.ts +50 -0
  127. package/dist/public-origin.js +180 -0
  128. package/dist/refusals.d.ts +86 -0
  129. package/dist/refusals.js +157 -0
  130. package/dist/relay.d.ts +107 -0
  131. package/dist/relay.js +655 -0
  132. package/dist/release-notes.d.ts +2 -0
  133. package/dist/release-notes.js +290 -0
  134. package/dist/relyon-cart-tokens.d.ts +101 -0
  135. package/dist/relyon-cart-tokens.js +521 -0
  136. package/dist/relyon.d.ts +141 -0
  137. package/dist/relyon.js +238 -0
  138. package/dist/robots.d.ts +27 -0
  139. package/dist/robots.js +127 -0
  140. package/dist/rules.d.ts +144 -0
  141. package/dist/rules.js +347 -0
  142. package/dist/sdk/generated/public-api.d.ts +4816 -0
  143. package/dist/sdk/generated/public-api.js +1 -0
  144. package/dist/sdk/index.d.ts +24 -0
  145. package/dist/sdk/index.js +34 -0
  146. package/dist/sdk/signatures.d.ts +17 -0
  147. package/dist/sdk/signatures.js +33 -0
  148. package/dist/setup.d.ts +37 -0
  149. package/dist/setup.js +94 -0
  150. package/dist/signatures.d.ts +112 -0
  151. package/dist/signatures.js +443 -0
  152. package/dist/state.d.ts +185 -0
  153. package/dist/state.js +96 -0
  154. package/dist/store-payments.d.ts +48 -0
  155. package/dist/store-payments.js +143 -0
  156. package/dist/structured-fields.d.ts +26 -0
  157. package/dist/structured-fields.js +200 -0
  158. package/dist/templates.d.ts +19 -0
  159. package/dist/templates.js +193 -0
  160. package/dist/test-checkout-command.d.ts +32 -0
  161. package/dist/test-checkout-command.js +161 -0
  162. package/dist/test-checkout.d.ts +88 -0
  163. package/dist/test-checkout.js +292 -0
  164. package/dist/types.d.ts +103 -0
  165. package/dist/types.js +18 -0
  166. package/dist/ucp-versions.d.ts +57 -0
  167. package/dist/ucp-versions.js +129 -0
  168. package/dist/util.d.ts +23 -0
  169. package/dist/util.js +68 -0
  170. package/dist/variants.d.ts +67 -0
  171. package/dist/variants.js +146 -0
  172. package/dist/version.d.ts +9 -0
  173. package/dist/version.js +10 -0
  174. package/dist/waiting.d.ts +43 -0
  175. package/dist/waiting.js +57 -0
  176. package/dist/webhook-command.d.ts +48 -0
  177. package/dist/webhook-command.js +367 -0
  178. package/dist/webhook-registration.d.ts +47 -0
  179. package/dist/webhook-registration.js +69 -0
  180. package/dist/webmcp-schema.d.ts +14 -0
  181. package/dist/webmcp-schema.js +140 -0
  182. package/dist/webmcp-script.d.ts +3 -0
  183. package/dist/webmcp-script.js +176 -0
  184. package/dist/webmcp-store.d.ts +102 -0
  185. package/dist/webmcp-store.js +116 -0
  186. package/dist/webmcp.d.ts +242 -0
  187. package/dist/webmcp.js +866 -0
  188. package/dist/wire-names.d.ts +85 -0
  189. package/dist/wire-names.js +109 -0
  190. package/package.json +118 -4
  191. package/release-notes.json +290 -0
  192. package/scripts/install-notice.cjs +7 -0
  193. package/skills/relyon-agents/SKILL.md +327 -0
  194. package/skills/relyon-catalog/SKILL.md +499 -0
  195. package/skills/relyon-catalog/references/example-store.md +218 -0
  196. package/skills/relyon-checkout/SKILL.md +603 -0
  197. package/skills/relyon-checkout/references/checkout-flow.md +257 -0
  198. package/skills/relyon-checkout/references/checkout-page.md +315 -0
  199. package/skills/relyon-go-live/SKILL.md +344 -0
  200. package/skills/relyon-orders/SKILL.md +191 -0
  201. package/skills/relyon-orders/references/webhook-receiver.md +113 -0
  202. package/skills/relyon-payments/SKILL.md +117 -0
  203. package/skills/relyon-setup/SKILL.md +1061 -0
  204. package/skills/relyon-setup/references/QUICKSTART.md +239 -0
  205. package/skills/relyon-setup/references/durable-state.md +209 -0
  206. package/skills/relyon-setup/references/express-server.md +388 -0
  207. package/skills/relyon-setup/references/next-app-router.md +251 -0
  208. package/templates/common/STORE-README.md +67 -0
  209. package/templates/common/gitignore +8 -0
  210. package/templates/common/scripts/check-pricing.ts +22 -0
  211. package/templates/common/scripts/serve.mjs +13 -0
  212. package/templates/common/server/catalog.ts +79 -0
  213. package/templates/common/server/checkout-flow.d.ts +34 -0
  214. package/templates/common/server/pages.ts +184 -0
  215. package/templates/common/server/storage.ts +114 -0
  216. package/templates/common/server/store.ts +67 -0
  217. package/templates/express/server/express.ts +20 -0
  218. package/templates/express/tsconfig.build.json +6 -0
  219. package/templates/express/tsconfig.json +9 -0
  220. package/templates/next/app/[[...path]]/route.ts +24 -0
  221. package/templates/next/next.config.mjs +19 -0
  222. package/templates/next/tsconfig.json +12 -0
  223. package/templates/payments/express.ts +39 -0
  224. package/templates/payments/next.ts +38 -0
  225. package/templates/payments/node.ts +39 -0
@@ -0,0 +1,124 @@
1
+ import { blockedEntry, claimAgent } from "./agents.js";
2
+ const HINT = /^[a-z0-9_.:-]{1,40}$/;
3
+ /** Headless or automation hints in the request. Claims only. */
4
+ export function behaviourHints(headers, extra = []) {
5
+ const hints = new Set();
6
+ const ua = headers.get("user-agent") ?? "";
7
+ if (/HeadlessChrome/i.test(ua) || /HeadlessChrome/i.test(headers.get("sec-ch-ua") ?? ""))
8
+ hints.add("headless_browser");
9
+ if (/\b(puppeteer|playwright|selenium|webdriver|phantomjs)\b/i.test(ua))
10
+ hints.add("automation_library");
11
+ for (const hint of extra)
12
+ if (HINT.test(hint))
13
+ hints.add(hint);
14
+ return [...hints];
15
+ }
16
+ const UNVERIFIED = { status: "unverified", reason: "no_signature" };
17
+ /** Names the agent at a request: verified from a signature when possible, otherwise as it claims. */
18
+ export async function identifyAgent(request, verifier, options) {
19
+ const claim = claimAgent(request.headers, options.mcpClientName);
20
+ const hints = behaviourHints(request.headers, options.hints);
21
+ const signed = request.headers.has("signature-input") && request.headers.has("signature");
22
+ let signature = UNVERIFIED;
23
+ if (signed && verifier) {
24
+ try {
25
+ signature = await verifier.verify(request, options.authorities);
26
+ }
27
+ catch {
28
+ signature = { status: "unverified", reason: "malformed" };
29
+ }
30
+ }
31
+ if (signature.status === "verified") {
32
+ return {
33
+ name: signature.name, verification: "verified", identified: true, method: signature.method, keyId: signature.keyId,
34
+ directory: signature.directory, claim, signature, hints,
35
+ };
36
+ }
37
+ return {
38
+ name: claim.name, verification: claim.name ? "claimed" : null, identified: claim.name !== null,
39
+ method: signature.method ?? null, keyId: claim.keyId ?? null, directory: null, claim, signature, hints,
40
+ };
41
+ }
42
+ function describe(entry) {
43
+ return [entry.name ? `name=${entry.name}` : null, entry.network ? `network=${entry.network}` : null, entry.key_id ? `key_id=${entry.key_id}` : null]
44
+ .filter(Boolean).join(" ");
45
+ }
46
+ /**
47
+ * Allow, refuse by a named Relyon rule, or (fail closed) refuse because the
48
+ * rules can't be read. These are the only outcomes: there is no challenge,
49
+ * score or blanket block. A person's browser is never blocked or failed
50
+ * closed; only a Relyon pause on a handed-off agent checkout (a channel the
51
+ * caller passes) applies to it.
52
+ */
53
+ export function decide(identity, rules, options = {}) {
54
+ if (identity.identified && !rules && options.failClosed !== false) {
55
+ return {
56
+ outcome: "unavailable", code: "service_unavailable", status: 503, identity,
57
+ message: "Agent checkout is unavailable: the store can't read its Relyon agent rules right now. Nothing was charged; try again shortly.",
58
+ };
59
+ }
60
+ if (!rules)
61
+ return { outcome: "allow", identity, rulesVersion: null };
62
+ const subjects = identity.identified ? [identity.claim] : [];
63
+ if (identity.verification === "verified") {
64
+ subjects.unshift({
65
+ name: identity.name, signals: ["verified-signature"],
66
+ ...(identity.method === "visa_tap" || identity.method === "mastercard_agent_pay" ? { network: identity.method } : {}),
67
+ ...(identity.keyId ? { keyId: identity.keyId } : {}),
68
+ });
69
+ }
70
+ for (const subject of subjects) {
71
+ const entry = blockedEntry(subject, rules.blocked_agents);
72
+ if (entry) {
73
+ const source = entry.source ?? "relyon";
74
+ const label = `${source} blocked_agents ${describe(entry)} (rules ${rules.version})`;
75
+ return {
76
+ outcome: "refuse", code: "agent_refused", status: 403, identity,
77
+ rule: { source, kind: "blocked_agents", entry, rulesVersion: rules.version, label },
78
+ message: `Refused by Relyon agent rule: ${label}. Nothing was charged.`,
79
+ };
80
+ }
81
+ }
82
+ const channel = options.channel;
83
+ if (channel && channel !== "web") {
84
+ const pausedChannel = rules.paused_channels.includes(channel) ? channel : rules.paused_channels.includes("agent") ? "agent" : null;
85
+ if (rules.paused || pausedChannel) {
86
+ const kind = rules.paused ? "paused" : "paused_channels";
87
+ const label = rules.paused ? `relyon paused (rules ${rules.version})` : `relyon paused_channels ${pausedChannel} (rules ${rules.version})`;
88
+ return {
89
+ outcome: "refuse", code: "channel_paused", status: 403, identity,
90
+ rule: { source: "relyon", kind, ...(pausedChannel && !rules.paused ? { channel: pausedChannel } : {}), rulesVersion: rules.version, label },
91
+ message: `Refused by Relyon agent rule: ${label}. Nothing was charged.`,
92
+ };
93
+ }
94
+ }
95
+ return { outcome: "allow", identity, rulesVersion: rules.version };
96
+ }
97
+ export function verifiedAgentSignal(decision) {
98
+ const identity = decision.identity;
99
+ const verified = identity.verification === "verified";
100
+ const skipChallenge = verified && decision.outcome === "allow";
101
+ const headers = { "relyon-agent-verified": verified ? "1" : "0" };
102
+ if (identity.name)
103
+ headers["relyon-agent"] = identity.name;
104
+ if (identity.verification)
105
+ headers["relyon-agent-verification"] = identity.verification;
106
+ return {
107
+ verified, skipChallenge, name: identity.name, method: identity.method, keyId: identity.keyId, directory: identity.directory, headers,
108
+ };
109
+ }
110
+ /** The shopper headers forwarded to Relyon on `createPayment`. Nothing else (no cookies, no authorization). */
111
+ export const FORWARDED_SHOPPER_HEADERS = ["user-agent", "signature-agent", "signature-input", "signature", "ucp-agent"];
112
+ /** The allowed shopper headers, as the shopper sent them (trimmed, no line breaks, at most 8 KiB each). */
113
+ export function forwardedShopperHeaders(headers) {
114
+ const out = {};
115
+ for (const name of FORWARDED_SHOPPER_HEADERS) {
116
+ const value = headers.get(name);
117
+ if (value === null || /[\r\n\0]/.test(value))
118
+ continue;
119
+ const trimmed = value.trim();
120
+ if (trimmed && trimmed.length <= 8192)
121
+ out[name] = trimmed;
122
+ }
123
+ return out;
124
+ }
@@ -0,0 +1,37 @@
1
+ import type { KitReleaseNote } from "./kit-updates.js";
2
+ export interface KitIdentity {
3
+ /** The npm package name, such as `@relyon/kit`. */
4
+ readonly name: string;
5
+ /** The package's exact version. */
6
+ readonly version: string;
7
+ /** The package's one bin (what `npx <name>` runs). */
8
+ readonly bin: string;
9
+ /** The release notes the package ships, when they differ from the kit's own. */
10
+ readonly releaseNotes?: readonly KitReleaseNote[];
11
+ }
12
+ /** `@relyon/kit` itself (a test keeps the version equal to its package.json). */
13
+ export declare const RELYON_KIT_IDENTITY: KitIdentity;
14
+ /** The legacy package name the wrapper keeps working. */
15
+ export declare const STORE_KIT_PACKAGE = "@relyon/store-kit";
16
+ /** The package running the kit: the declared identity, else `@relyon/kit`. */
17
+ export declare function kitIdentity(): KitIdentity;
18
+ /**
19
+ * Declares the package running the kit. Call it before anything loads the
20
+ * kit's modules (the wrapper does so in its first import). The first valid
21
+ * declaration wins; the return value is the identity in force.
22
+ */
23
+ export declare function declareKitIdentity(identity: KitIdentity): KitIdentity;
24
+ /** `npx <package>`: how users run this package's CLI. */
25
+ export declare function kitCommand(identity?: KitIdentity): string;
26
+ /** The exact install spec for this package, such as `@relyon/kit@1.0.0`. */
27
+ export declare function kitSpec(identity?: KitIdentity): string;
28
+ /**
29
+ * The kit's text names commands as `@relyon/store-kit` (the wrapper's own
30
+ * wording). Run by `@relyon/kit`, every such mention names `@relyon/kit`
31
+ * instead, so printed commands and written instructions run the package that
32
+ * is installed; a pinned spec (`@relyon/store-kit@0.1.52`) becomes this
33
+ * package's own (`@relyon/kit@1.0.0`). HTML comments are left alone: they hold
34
+ * the markers init finds its blocks by, which stay the same for both packages.
35
+ * Run by the wrapper, the text is unchanged.
36
+ */
37
+ export declare function forKitPackage(text: string, identity?: KitIdentity): string;
@@ -0,0 +1,54 @@
1
+ /** `@relyon/kit` itself (a test keeps the version equal to its package.json). */
2
+ export const RELYON_KIT_IDENTITY = Object.freeze({ name: "@relyon/kit", version: "1.0.0", bin: "relyon-kit" });
3
+ /** The legacy package name the wrapper keeps working. */
4
+ export const STORE_KIT_PACKAGE = "@relyon/store-kit";
5
+ const IDENTITY = Symbol.for("@relyon/kit.identity");
6
+ function validIdentity(value) {
7
+ return !!value && typeof value === "object"
8
+ && typeof value.name === "string" && /^@relyon\/[a-z-]+$/.test(value.name)
9
+ && typeof value.version === "string" && /^\d+\.\d+\.\d+$/.test(value.version)
10
+ && typeof value.bin === "string" && /^[a-z-]+$/.test(value.bin);
11
+ }
12
+ /** The package running the kit: the declared identity, else `@relyon/kit`. */
13
+ export function kitIdentity() {
14
+ const declared = globalThis[IDENTITY];
15
+ return validIdentity(declared) ? declared : RELYON_KIT_IDENTITY;
16
+ }
17
+ /**
18
+ * Declares the package running the kit. Call it before anything loads the
19
+ * kit's modules (the wrapper does so in its first import). The first valid
20
+ * declaration wins; the return value is the identity in force.
21
+ */
22
+ export function declareKitIdentity(identity) {
23
+ const holder = globalThis;
24
+ if (!validIdentity(holder[IDENTITY]) && validIdentity(identity)) {
25
+ Object.defineProperty(holder, IDENTITY, { value: Object.freeze({ ...identity }), enumerable: false, configurable: false, writable: false });
26
+ }
27
+ return kitIdentity();
28
+ }
29
+ /** `npx <package>`: how users run this package's CLI. */
30
+ export function kitCommand(identity = kitIdentity()) {
31
+ return `npx ${identity.name}`;
32
+ }
33
+ /** The exact install spec for this package, such as `@relyon/kit@1.0.0`. */
34
+ export function kitSpec(identity = kitIdentity()) {
35
+ return `${identity.name}@${identity.version}`;
36
+ }
37
+ /**
38
+ * The kit's text names commands as `@relyon/store-kit` (the wrapper's own
39
+ * wording). Run by `@relyon/kit`, every such mention names `@relyon/kit`
40
+ * instead, so printed commands and written instructions run the package that
41
+ * is installed; a pinned spec (`@relyon/store-kit@0.1.52`) becomes this
42
+ * package's own (`@relyon/kit@1.0.0`). HTML comments are left alone: they hold
43
+ * the markers init finds its blocks by, which stay the same for both packages.
44
+ * Run by the wrapper, the text is unchanged.
45
+ */
46
+ export function forKitPackage(text, identity = kitIdentity()) {
47
+ if (identity.name === STORE_KIT_PACKAGE || !/@relyon\/store-kit|\.bin\/store-kit/.test(text))
48
+ return text;
49
+ return text.split(/(<!--[\s\S]*?-->)/).map((part, index) => index % 2 ? part : part
50
+ .replace(/@relyon\/store-kit@\d+\.\d+\.\d+(?:-[\w.]+)?(?![\w.-])/g, kitSpec(identity))
51
+ .replace(/@relyon\/store-kit(?![\w-])/g, identity.name)
52
+ .replace(/\bInit installs kit `\d+\.\d+\.\d+(?:-[\w.]+)?`/g, `Init installs kit \`${identity.version}\``)
53
+ .replace(/\.bin\/store-kit(?![\w-])/g, `.bin/${identity.bin}`)).join("");
54
+ }
@@ -0,0 +1,42 @@
1
+ export { StoreKit, createStoreKit, createKit, BodyTooLargeError, DEFAULT_ORDER_CLAIM_LEASE_MS, type StoreKitOptions, type Kit, type KitOptions } from "./kit.js";
2
+ export { DEFAULT_PATHS, type KitPaths, type OrderOnce } from "./context.js";
3
+ export * from "./types.js";
4
+ export { RelyonGateway, RelyonProblemError, RelyonUnavailableError, RelyonAccountNotReadyError, ACCOUNT_NOT_READY_CODES, isAccountNotReadyCode, liveModeFor, cardFieldsScriptUrl, type AccountNotReadyCode, type RelyonConnection, type FetchLike, } from "./relyon.js";
5
+ export { assertLiveStoreUrls, nonPublicStoreHost } from "./live.js";
6
+ export { AgentEventQueue, MemoryAgentEventStore, requestFacts, type AgentEventStore, type AgentEventQueueOptions, type AgentEventStats, type NewAgentEvent } from "./events.js";
7
+ export { AgentRulesCache, DOCTOR_ACKNOWLEDGEMENT_HEADER, doctorAcknowledgement, isAgentRules, type AgentRulesOptions } from "./rules.js";
8
+ export { claimAgent, blockedEntry, type AgentClaim } from "./agents.js";
9
+ export { refusal, mcpErrorBody, MCP_ERROR_CODES, paymentOutcomeUnknown, PAYMENT_OUTCOME_UNKNOWN, PAYMENT_OUTCOME_UNKNOWN_STATUS, PAYMENT_OUTCOME_UNKNOWN_RETRY_AFTER, PAYMENT_STATUS_HEADER, EXISTING_CHECKOUT_NOTE, EXISTING_CHECKOUT_NOTE_MCP, type RefusalCode, type RefusalProtocol, type PaymentOutcomeUnknownOptions, } from "./refusals.js";
10
+ export { ORDER_PENDING, ORDER_PENDING_ERROR_STATUS, ORDER_PENDING_RETRY_AFTER, ORDER_STATUS_HEADER, orderPendingCheckout, orderPendingError, orderPendingMcp } from "./order-pending.js";
11
+ export { MemoryCheckoutStateStore, type CheckoutOrderPending, type CheckoutRecord, type CheckoutStateStore, type StorePaymentRecord, type OrderClaimOptions, type OrderClaimStatus, type HandoffTokenClaimOptions, type HandoffTokenSetOptions } from "./state.js";
12
+ export { SealedCartTokens, type CartTokenResolver, type ResolvedCart } from "./cart-tokens.js";
13
+ export { AgentRefusedError, PaymentUnavailableError, PaymentOutcomeUnknownError, RelyonRuleRefusalError, CHANNEL_FOR, legacyPaymentCart, paymentIdempotencyKey, chargeNeutralGateMessage, PAY_CHARGE_NEUTRAL_NOTE, type CardFields, type CardFieldsInput, type CreatePaymentInput, type CreatePaymentResult, type PendingPayment, type Landing, type LandingInput, CHECKOUT_CART_ITEMS_ATTRIBUTE, cartItemCount, } from "./checkout.js";
14
+ export { CatalogHolder, CatalogSyncError, type CatalogPersistence, type CatalogSyncResult } from "./catalog.js";
15
+ export { formatCatalogIssue } from "./catalog-enrichment.js";
16
+ export { productJsonLd, renderProductJsonLd, productListJsonLd, renderProductListJsonLd, feedLabel, llmsTxt, productSitemap, decimalAmount, type LlmsTxtExtras, type ProductJsonLd, type StoreInfo, type UcpProfile } from "./discovery.js";
17
+ export { agentCard, AP2_EXTENSION_URI, type AgentCardInput } from "./agent-card.js";
18
+ export { MCP_TOOLS } from "./mcp.js";
19
+ export type { StoreDomain, StorePolicies, StorePoliciesInput } from "./setup.js";
20
+ export { normalizeStorePolicies, policyCheckoutLinks, policyLlmsLines, merchantReturnPolicy, returnsSentence, withPolicyLinks, planStorePolicySync, type StorePolicySyncChange, type StorePolicySyncConfirmed, type StorePolicySyncPlan, type StorePolicyOptions, type StoreReturnsPolicy, type StoreReturnScope } from "./policies.js";
21
+ export * from "./feed-values.js";
22
+ export * from "./feed-mapping.js";
23
+ export * from "./catalog-reads.js";
24
+ export * from "./feeds.js";
25
+ export * from "./robots.js";
26
+ export { readResult, relayIdempotencyKey, type RelayedResult, type UnknownPaymentStatus } from "./relay.js";
27
+ export { ucpInputs, acpInputs, mcpInputs, mergeInputs } from "./protocol-inputs.js";
28
+ export { AgentSignatureVerifier, MemoryNonceStore, DEFAULT_WEB_BOT_AUTH_DIRECTORIES, WEB_BOT_AUTH_DIRECTORY_PATH, WEB_BOT_AUTH_TAG, NETWORK_TAGS, ed25519Thumbprint, parseEd25519Jwks, signatureAgentUrl, type AgentVerificationOptions, type NetworkDirectoryConfig, type NonceStore, type SignatureFailure, type SignatureMethod, type SignatureNetwork, type SignatureVerdict, type DirectoryFetch, } from "./signatures.js";
29
+ export { identifyAgent, decide, behaviourHints, verifiedAgentSignal, forwardedShopperHeaders, FORWARDED_SHOPPER_HEADERS, type AgentIdentity, type AgentVerification, type AgentDecision, type DecideOptions, type IdentifyOptions, type RelyonRuleRef, type VerifiedAgentSignal, } from "./identify.js";
30
+ export { orderConfirmation, orderRefusal, orderJsonLd, renderOrderConfirmation, renderOrderRefusal, schemaOrderStatus, type OrderConfirmation, type OrderRefusal, } from "./confirmation.js";
31
+ export { WebMcpCheckouts, MemoryWebMcpCheckoutStore, WEBMCP_TOOLS, refusalFor, WEBMCP_APPROVAL_TTL_MS, webMcpSessionCookieName, type WebMcpCheckout, type WebMcpCheckoutStore, type WebMcpOptions, type WebMcpTool, type CreateWebMcpCheckoutInput, type WebMcpCheckoutPage, type WebMcpApproval, type WebMcpPendingPayment, } from "./webmcp.js";
32
+ export { SharedWebMcpCheckoutStore, MemoryAtomicKeyValueStore, applyApprovalClaim, type WebMcpApprovalClaim, type AtomicKeyValueStore, type VersionedValue, type SharedWebMcpCheckoutStoreOptions, } from "./webmcp-store.js";
33
+ export { webMcpScript, WEBMCP_TOOL_HEADER } from "./webmcp-script.js";
34
+ export { GET_CHECKOUT_SCHEMA, UPDATE_CHECKOUT_SCHEMA, COMPLETE_CHECKOUT_SCHEMA, validateToolInput, containsCardData } from "./webmcp-schema.js";
35
+ export { CART_TRANSFER_KEY_ENV, CART_TRANSFER_KEY_HEADER, CART_TRANSFER_PARAM, TransferTokens, cartTransferState, transferableItems, type CartTransferOption, type CartTransferState, } from "./cart-transfer.js";
36
+ export { UCP_CURRENT_VERSION, UCP_2026_04_08, UCP_2026_04_08_PROFILE_PATH, UCP_2026_04_08_SEGMENT, CART_CAPABILITY, CART_CAPABILITY_2026_08_25, CAPABILITIES_2026_04_08, SHOPPING_REST_2026_04_08, currentProfile, profile20260408, type StoreUcpVersion, type ProfileAdditions, } from "./ucp-versions.js";
37
+ export { RelyonPayments, createPayments, chargeIdempotencyKey, PaymentOutcomeUnknown, DEFAULT_PAYMENTS_BASE_URL, type PaymentsOptions, type PaymentSessionInput, type PaymentCardFieldsInput, type PaymentCardFields, type HostedCardPaymentMethod, type ChargeInput, type ChargeResult, type RefundInput, type RefundResult, type WebhookInput, } from "./payments.js";
38
+ export { PaymentRoutes, createPaymentRoutes, DEFAULT_PAYMENT_ROUTES, type PaymentRoutesOptions, type PaymentRoutePaths, type OrderAmount } from "./payments-routes.js";
39
+ export { kitEnvironment, publicUrlFromEnv, projectSpaceFromEnv, type KitEnvironment } from "./kit-environment.js";
40
+ export { KIT_LAYERS, KIT_LAYER_LABELS, KIT_CONFIG_FILE, readKitConfig, isKitLayer, type KitLayer, type KitConfig } from "./kit-config.js";
41
+ export { kitIdentity, declareKitIdentity, RELYON_KIT_IDENTITY, STORE_KIT_PACKAGE, type KitIdentity } from "./identity.js";
42
+ export * as wireNames from "./wire-names.js";
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ export { StoreKit, createStoreKit, createKit, BodyTooLargeError, DEFAULT_ORDER_CLAIM_LEASE_MS } from "./kit.js";
2
+ export { DEFAULT_PATHS } from "./context.js";
3
+ export * from "./types.js";
4
+ export { RelyonGateway, RelyonProblemError, RelyonUnavailableError, RelyonAccountNotReadyError, ACCOUNT_NOT_READY_CODES, isAccountNotReadyCode, liveModeFor, cardFieldsScriptUrl, } from "./relyon.js";
5
+ export { assertLiveStoreUrls, nonPublicStoreHost } from "./live.js";
6
+ export { AgentEventQueue, MemoryAgentEventStore, requestFacts } from "./events.js";
7
+ export { AgentRulesCache, DOCTOR_ACKNOWLEDGEMENT_HEADER, doctorAcknowledgement, isAgentRules } from "./rules.js";
8
+ export { claimAgent, blockedEntry } from "./agents.js";
9
+ export { refusal, mcpErrorBody, MCP_ERROR_CODES, paymentOutcomeUnknown, PAYMENT_OUTCOME_UNKNOWN, PAYMENT_OUTCOME_UNKNOWN_STATUS, PAYMENT_OUTCOME_UNKNOWN_RETRY_AFTER, PAYMENT_STATUS_HEADER, EXISTING_CHECKOUT_NOTE, EXISTING_CHECKOUT_NOTE_MCP, } from "./refusals.js";
10
+ export { ORDER_PENDING, ORDER_PENDING_ERROR_STATUS, ORDER_PENDING_RETRY_AFTER, ORDER_STATUS_HEADER, orderPendingCheckout, orderPendingError, orderPendingMcp } from "./order-pending.js";
11
+ export { MemoryCheckoutStateStore } from "./state.js";
12
+ export { SealedCartTokens } from "./cart-tokens.js";
13
+ export { AgentRefusedError, PaymentUnavailableError, PaymentOutcomeUnknownError, RelyonRuleRefusalError, CHANNEL_FOR, legacyPaymentCart, paymentIdempotencyKey, chargeNeutralGateMessage, PAY_CHARGE_NEUTRAL_NOTE, CHECKOUT_CART_ITEMS_ATTRIBUTE, cartItemCount, } from "./checkout.js";
14
+ export { CatalogHolder, CatalogSyncError } from "./catalog.js";
15
+ export { formatCatalogIssue } from "./catalog-enrichment.js";
16
+ export { productJsonLd, renderProductJsonLd, productListJsonLd, renderProductListJsonLd, feedLabel, llmsTxt, productSitemap, decimalAmount } from "./discovery.js";
17
+ export { agentCard, AP2_EXTENSION_URI } from "./agent-card.js";
18
+ export { MCP_TOOLS } from "./mcp.js";
19
+ export { normalizeStorePolicies, policyCheckoutLinks, policyLlmsLines, merchantReturnPolicy, returnsSentence, withPolicyLinks, planStorePolicySync } from "./policies.js";
20
+ export * from "./feed-values.js";
21
+ export * from "./feed-mapping.js";
22
+ export * from "./catalog-reads.js";
23
+ export * from "./feeds.js";
24
+ export * from "./robots.js";
25
+ export { readResult, relayIdempotencyKey } from "./relay.js";
26
+ export { ucpInputs, acpInputs, mcpInputs, mergeInputs } from "./protocol-inputs.js";
27
+ export { AgentSignatureVerifier, MemoryNonceStore, DEFAULT_WEB_BOT_AUTH_DIRECTORIES, WEB_BOT_AUTH_DIRECTORY_PATH, WEB_BOT_AUTH_TAG, NETWORK_TAGS, ed25519Thumbprint, parseEd25519Jwks, signatureAgentUrl, } from "./signatures.js";
28
+ export { identifyAgent, decide, behaviourHints, verifiedAgentSignal, forwardedShopperHeaders, FORWARDED_SHOPPER_HEADERS, } from "./identify.js";
29
+ export { orderConfirmation, orderRefusal, orderJsonLd, renderOrderConfirmation, renderOrderRefusal, schemaOrderStatus, } from "./confirmation.js";
30
+ export { WebMcpCheckouts, MemoryWebMcpCheckoutStore, WEBMCP_TOOLS, refusalFor, WEBMCP_APPROVAL_TTL_MS, webMcpSessionCookieName, } from "./webmcp.js";
31
+ export { SharedWebMcpCheckoutStore, MemoryAtomicKeyValueStore, applyApprovalClaim, } from "./webmcp-store.js";
32
+ export { webMcpScript, WEBMCP_TOOL_HEADER } from "./webmcp-script.js";
33
+ export { GET_CHECKOUT_SCHEMA, UPDATE_CHECKOUT_SCHEMA, COMPLETE_CHECKOUT_SCHEMA, validateToolInput, containsCardData } from "./webmcp-schema.js";
34
+ export { CART_TRANSFER_KEY_ENV, CART_TRANSFER_KEY_HEADER, CART_TRANSFER_PARAM, TransferTokens, cartTransferState, transferableItems, } from "./cart-transfer.js";
35
+ export { UCP_CURRENT_VERSION, UCP_2026_04_08, UCP_2026_04_08_PROFILE_PATH, UCP_2026_04_08_SEGMENT, CART_CAPABILITY, CART_CAPABILITY_2026_08_25, CAPABILITIES_2026_04_08, SHOPPING_REST_2026_04_08, currentProfile, profile20260408, } from "./ucp-versions.js";
36
+ export { RelyonPayments, createPayments, chargeIdempotencyKey, PaymentOutcomeUnknown, DEFAULT_PAYMENTS_BASE_URL, } from "./payments.js";
37
+ export { PaymentRoutes, createPaymentRoutes, DEFAULT_PAYMENT_ROUTES } from "./payments-routes.js";
38
+ export { kitEnvironment, publicUrlFromEnv, projectSpaceFromEnv } from "./kit-environment.js";
39
+ export { KIT_LAYERS, KIT_LAYER_LABELS, KIT_CONFIG_FILE, readKitConfig, isKitLayer } from "./kit-config.js";
40
+ export { kitIdentity, declareKitIdentity, RELYON_KIT_IDENTITY, STORE_KIT_PACKAGE } from "./identity.js";
41
+ export * as wireNames from "./wire-names.js";
package/dist/init.d.ts ADDED
@@ -0,0 +1,157 @@
1
+ import { type KitLayer } from "./kit-config.js";
2
+ import { type PaymentsFramework } from "./payments-init.js";
3
+ import { type AutoSetupResult, type AutoSetupStatus } from "./private-config.js";
4
+ import { type StoreTemplate } from "./templates.js";
5
+ /** The one documented store brief path, relative to the project root. */
6
+ export declare const STORE_BRIEF_FILE = "relyon-store-brief.md";
7
+ /** The skills every agent gets, in the order the flow uses them. */
8
+ export declare const INIT_SKILLS: readonly ["relyon-setup", "relyon-catalog", "relyon-checkout", "relyon-agents", "relyon-orders", "relyon-go-live"];
9
+ /** Where each agent reads project skills. */
10
+ export declare const SKILL_DESTINATIONS: readonly [{
11
+ readonly dir: ".agents/skills";
12
+ readonly agents: "Codex, Replit Agent, OpenCode";
13
+ }, {
14
+ readonly dir: ".claude/skills";
15
+ readonly agents: "Claude Code";
16
+ }, {
17
+ readonly dir: ".cursor/skills";
18
+ readonly agents: "Cursor";
19
+ }];
20
+ /** The first instruction in QUICKSTART, the AGENTS.md / CLAUDE.md block and init's closing lines. */
21
+ export declare const SETUP_FIRST = "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).";
22
+ /** The last instruction in the same places. */
23
+ export declare const DOCTOR_LAST = "Finish with `npx @relyon/store-kit doctor` and fix every FAIL.";
24
+ /** When automatic Test setup can't run: exactly one URL and one command. */
25
+ export declare const GET_KEY_LINES: readonly [" 1) Get a free Test key: https://core.getrelyon.com/get-sandbox-key", " 2) Then run: npx @relyon/store-kit init --key-from-stdin"];
26
+ export declare const POINTER_BEGIN = "<!-- BEGIN relyon (written by npx @relyon/store-kit init; edit outside this block) -->";
27
+ export declare const POINTER_END = "<!-- END relyon -->";
28
+ /** The longest store idea `--store` accepts, in characters. */
29
+ export declare const STORE_IDEA_MAX = 4000;
30
+ /**
31
+ * Runs the package manager. Arguments are a fixed argv list, never a shell string.
32
+ * Any text it returns is the package manager's output, printed through key redaction.
33
+ */
34
+ export type InstallRunner = (command: string, args: readonly string[], cwd: string) => Promise<string | void> | string | void;
35
+ export interface InitOptions {
36
+ /** The app's directory. */
37
+ cwd: string;
38
+ /**
39
+ * The layer (`--payments`, `--products`, `--pages`), recorded in
40
+ * relyon/kit.json. Unset: the store kit's own init (no layer recorded).
41
+ */
42
+ layer?: KitLayer | undefined;
43
+ /** Payments only: the helper's framework. Default: from the app's package.json. */
44
+ framework?: PaymentsFramework | undefined;
45
+ /** Opt-in working Test store; the target must be new or completely empty. */
46
+ template?: StoreTemplate | undefined;
47
+ /** The merchant's store idea, written verbatim to the store brief. */
48
+ store?: string | undefined;
49
+ /** Replace differing skill files and the store brief, and only the marked Relyon block in AGENTS.md / CLAUDE.md. */
50
+ force?: boolean | undefined;
51
+ /** Don't add the kit dependency. */
52
+ skipInstall?: boolean | undefined;
53
+ /** The skills to copy. Default: this package's own `skills/`. */
54
+ skillsDir?: string | undefined;
55
+ /** Test seam for template assets; defaults to this package's templates/. */
56
+ templatesDir?: string | undefined;
57
+ /** Runs the package manager. Default: spawns it without a shell. */
58
+ install?: InstallRunner | undefined;
59
+ /** One line of output. Default: stdout. Everything passes through key redaction. */
60
+ out?: ((line: string) => void) | undefined;
61
+ /** Test seam; default uses process environment and bounded public Test provisioning. */
62
+ autoSetup?: ((options: {
63
+ project: string;
64
+ optIn?: boolean;
65
+ scratch?: boolean;
66
+ }) => Promise<AutoSetupResult | AutoSetupStatus>) | undefined;
67
+ /** Test seam: the best-effort webhook registration after automatic Test setup. Default: the real one. */
68
+ webhookSetup?: ((options: {
69
+ project: string;
70
+ storeUrl: string;
71
+ env?: NodeJS.ProcessEnv;
72
+ }) => Promise<string>) | undefined;
73
+ /**
74
+ * `--auto-test-key`: accepted for scripts; init no longer creates sandboxes
75
+ * (sandbox creation is authenticated and lives on the hosted key page), so
76
+ * it changes nothing, as RELYON_AUTO_TEST_KEY=true does not.
77
+ */
78
+ autoTestKey?: boolean | undefined;
79
+ /**
80
+ * `--key-from-stdin`: reads a Test key the merchant pastes (stdin or a
81
+ * hidden prompt). Never a command-line argument; the key is never printed.
82
+ */
83
+ readKey?: (() => Promise<string>) | undefined;
84
+ /** Test seam: the environment used to find the private folder for an entered key. Default process.env. */
85
+ env?: NodeJS.ProcessEnv | undefined;
86
+ /**
87
+ * The template was written into a scratch folder (`--template … --dir`).
88
+ * Init never creates a sandbox for it; add a Test key with --key-from-stdin.
89
+ */
90
+ scratchTemplate?: boolean | undefined;
91
+ /** Test seam: the Node.js version the Express template is checked against. Default process.versions.node. */
92
+ nodeVersion?: string | undefined;
93
+ /** `--agent-hooks`: also merge a Relyon stop hook into Claude Code, Cursor and Copilot hook files. Default off. */
94
+ agentHooks?: boolean | undefined;
95
+ }
96
+ /** What automatic Test setup did, without any secret. */
97
+ export declare function setupLines(setup: AutoSetupResult): string[];
98
+ export interface InitConflict {
99
+ file: string;
100
+ reason: string;
101
+ addByHand?: string;
102
+ }
103
+ export interface InitResult {
104
+ exitCode: 0 | 1 | 2;
105
+ written: string[];
106
+ unchanged: string[];
107
+ conflicts: InitConflict[];
108
+ install: "installed" | "already installed" | "skipped" | "failed" | "not run";
109
+ /**
110
+ * Where the kit was (or would be) added, relative to the project, when that
111
+ * isn't the project itself: a package of the pnpm workspace whose root init ran in.
112
+ */
113
+ installDir?: string;
114
+ /** Set when init skipped the install at a pnpm workspace root: the command to run in the server package. */
115
+ installNote?: string;
116
+ }
117
+ /** A refusal of the command line or the project, before anything is written. */
118
+ export declare class InitError extends Error {
119
+ }
120
+ /** The package manager's add command for the pinned kit, from the app's lockfile. */
121
+ export declare function installCommand(project: string): Promise<{
122
+ command: string;
123
+ args: string[];
124
+ manager: string;
125
+ }>;
126
+ /** The pointer block for an agent instructions file. */
127
+ export declare function pointerBlock(skillsDir: string): string;
128
+ /** The line a merchant adds by hand when init may not change their file. */
129
+ export declare function pointerLine(skillsDir: string): string;
130
+ /** Why a store idea can't be written, without repeating any of it; null when it is fine. */
131
+ export declare function storeIdeaProblem(idea: string): string | null;
132
+ /** The store brief: the idea verbatim, fenced so nothing in it can end the fence. */
133
+ export declare function storeBrief(idea: string): string;
134
+ /**
135
+ * The one marked Relyon block, as character offsets, when the file has exactly
136
+ * one BEGIN line followed by exactly one END line, each on a line of its own;
137
+ * null when it has no marker at all; "ambiguous" for anything else.
138
+ */
139
+ export declare function markedBlock(text: string): {
140
+ begin: number;
141
+ end: number;
142
+ } | null | "ambiguous";
143
+ /** The oldest Node.js the Express template runs on (its package.json engines). */
144
+ export declare const EXPRESS_MIN_NODE = "22.13.0";
145
+ /** Why this Node.js can't run the Express template, or null when it can. */
146
+ export declare function expressNodeProblem(version: string): string | null;
147
+ /**
148
+ * The generated package's name: the folder's name made a valid npm name. A
149
+ * name that equals one of the template's own dependencies (a folder called
150
+ * "express" or "next") gets "-store" appended, because npm refuses to install
151
+ * a package under a project of the same name.
152
+ */
153
+ export declare function sanitizedPackageName(project: string): string;
154
+ /** The Next.js major versions the Next.js App Router reference covers. */
155
+ export declare const NEXT_REFERENCE_MAJORS: readonly string[];
156
+ /** Runs init. Returns the exit code: 0 done, 1 conflicts or a failed install, 2 a refused command or project. */
157
+ export declare function runInit(options: InitOptions): Promise<InitResult>;